Opened 23 months ago
Last modified 19 months ago
#34322 closed Bug
ManifestStaticFilesStorage crashes on commented JavaScript import statements — at Version 3
Reported by: | Adam Johnson | Owned by: | nobody |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 4.2 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
#32319 added module support to ManifestStaticFilesStorage
. It can crash with imports in comments, which are used for Typescript (docs) but don't necessarily resolve when code is bundled.
Example 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[]} */
Change History (3)
comment:1 by , 23 months ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 23 months ago
Summary: | ManifestStaticFilesStorage crashes → ManifestStaticFilesStorage crashes on commented JavaScript import statements |
---|
comment:3 by , 23 months ago
Description: | modified (diff) |
---|
Added more detail to description about possible failures
Note:
See TracTickets
for help on using tickets.
Grrr. OK. Sigh. Thanks for the report Adam. (I didn't run it, but I'm going to trust you)
(Mariusz was right to be sceptical that this was going to be OK. . :)
Let's look at a fix here but: