#34322: ManifestStaticFilesStorage crashes on commented JavaScript import
statements
-------------------------------------+------------------------------------
Reporter: Adam Johnson | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Old description:
> #32319 added module support to `ManifestStaticFilesStorage`. It can crash
> with imports in comments, which bundlers like Webpack can leave in.
>
> Example:
>
> {{{
> //** @type {import("./htmx").HtmxApi} */
> }}}
>
> Leads to:
>
> {{{
> whitenoise.storage.MissingFileError: The file 'example/dist/htmx' could
> not be found with
> <whitenoise.storage.CompressedManifestStaticFilesStorage object at
> 0x16ff630a0>.
>
> The JS file 'example/dist/app.js' references a file which could not be
> found:
> example/dist/htmx
>
> Please check the URL references in this JS file, particularly any
> relative paths which might be pointing to the wrong location.
> }}}
>
> The regex should be adjusted to only select imports that are alone on a
> line, with whitespace.
New description:
#32319 added module support to `ManifestStaticFilesStorage`. It can crash
with imports in comments, which are used for Typescript
([https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
#import-types docs]) but don't necessarily resolve when code is bundled.
Example [https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js
from htmx]:
{{{
//** @type {import("./htmx").HtmxApi} */
}}}
Leads to:
{{{
whitenoise.storage.MissingFileError: The file 'example/dist/htmx' could
not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage
object at 0x16ff630a0>.
The JS file 'example/dist/app.js' references a file which could not be
found:
example/dist/htmx
Please check the URL references in this JS file, particularly any
relative paths which might be pointing to the wrong location.
}}}
The regex should be adjusted to only select imports that are alone on a
line, with whitespace.
This may be a challenge as comments can be multi-line like:
{{{
/**
* @param {HTMLElement} elt
* @returns {import("./htmx").HtmxTriggerSpecification[]}
*/
}}}
--
Comment (by Adam Johnson):
Added more detail to description about possible failures
--
Ticket URL: <https://code.djangoproject.com/ticket/34322#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018635dff19a-ce51e75d-3171-4088-86e6-2bc4714657e0-000000%40eu-central-1.amazonses.com.