#33237 closed Bug (fixed)
ManifestStaticFilesStorage doesn't update JavaScript source map references in multiline files
Reported by: | Joseph Abrahams | Owned by: | Carlton Gibson |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 4.0 |
Severity: | Release blocker | Keywords: | |
Cc: | Adam Johnson, gilmrjc | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Current implementation of HashedFilesMixin
relies on regex multiline mode to parse out the sourceMappingURL comment. As is, the filename is only correctly replaced when the comment is the first and only line in the JS file (exception to final single new line at EOF).
Steps to reproduce:
- Include static multi-line javascript file that contains a valid sourceMappingURL comment in a project with
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
- Run
python manage.py collectstatic
- Open the new hashed javascript file and observe the unmodified sourceMappingURL comment
See updated, failing test case: https://joseph.is/3CrvpSW.
More than happy to work on a patch provided some guidance on expected functionality.
Change History (6)
comment:1 by , 3 years ago
Cc: | added |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 3 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
PR switching the regex to multiline mode.
Joseph, if you're able to have a look, that would be great.
comment:3 by , 3 years ago
Cc: | added |
---|
Looks like the regression was introduced in 781b44240a06f0c868254f40f36ce46c927f56d1 as part of #32319.
(The multiline flag was removed switching to named groups.)
comment:4 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Thanks for the report, it's a bug in a new feature introduced in e32722d1606794f0a85d74811e53a0336a1ce305 (see #32383).