[Django] #32383: ManifestStaticFilesStorage doesn't update JavaScript source map references

37 views
Skip to first unread message

Django

unread,
Jan 25, 2021, 10:29:47 AM1/25/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-----------------------------------------------+------------------------
Reporter: Adam Johnson | Owner: nobody
Type: New feature | Status: new
Component: contrib.staticfiles | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+------------------------
ManifestStaticFilesStorage replaces URL's in CSS files with the hashed
equivalents, but doesn't have any other out-of-the-box rules. One common
use case for cross-static-file-references is a
[https://developer.mozilla.org/en-
US/docs/Tools/Debugger/How_to/Use_a_source_map JavaScript source map], a
structured comment in a JS file.

I think it would be a reasonable inclusion that Django modifies these too.
I got it working (with Whitenoise's subclass of
`ManifestStaticFilesStorage`) with this extra regex pattern:

{{{
from whitenoise.storage import CompressedManifestStaticFilesStorage


class SuperStaticFilesStorage(CompressedManifestStaticFilesStorage):
patterns = CompressedManifestStaticFilesStorage.patterns + (
(
"*.js",
(
(
r"(//# sourceMappingURL=(.*?\.js\.map))$",
"//# sourceMappingURL=%s",
),
),
),
)

}}}

Ideally the regex would start with a ^", which requires the regex
mulitline flag, and would NOT be compiled in case-insenstive mode. The
current storage implementation forces compiling regexes with only the case
insensitive flag.

--
Ticket URL: <https://code.djangoproject.com/ticket/32383>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 25, 2021, 1:17:07 PM1/25/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Kiran
| Baby
Type: New feature | Status: assigned
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kiran Baby):

* owner: nobody => Kiran Baby
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:1>

Django

unread,
Jan 25, 2021, 9:40:49 PM1/25/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: (none)

Type: New feature | Status: new
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kiran Baby):

* owner: Kiran Baby => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:2>

Django

unread,
Jan 26, 2021, 2:20:05 AM1/26/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+------------------------------------

Reporter: Adam Johnson | Owner: (none)
Type: New feature | Status: new
Component: contrib.staticfiles | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Yep. If we can do this then super 👍

--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:3>

Django

unread,
Jan 26, 2021, 4:27:50 PM1/26/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson

Type: New feature | Status: assigned
Component: contrib.staticfiles | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* owner: (none) => Adam Johnson


* status: new => assigned


Old description:

New description:

{{{
from whitenoise.storage import CompressedManifestStaticFilesStorage

}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:4>

Django

unread,
Jan 26, 2021, 6:13:22 PM1/26/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: contrib.staticfiles | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:5>

Django

unread,
Apr 2, 2021, 2:13:49 AM4/2/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: assigned
Component: contrib.staticfiles | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:6>

Django

unread,
Apr 2, 2021, 6:54:08 AM4/2/21
to django-...@googlegroups.com
#32383: ManifestStaticFilesStorage doesn't update JavaScript source map references
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: New feature | Status: closed
Component: contrib.staticfiles | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e32722d1606794f0a85d74811e53a0336a1ce305" e32722d1]:
{{{
#!CommitTicketReference repository=""
revision="e32722d1606794f0a85d74811e53a0336a1ce305"
Fixed #32383 -- Added source map support to ManifestStaticFilesStorage.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32383#comment:7>

Reply all
Reply to author
Forward
0 new messages