#34563: ManifestStaticFilesStorage support for CSS module scripts in Javascript
files.
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: blighj
Type: New feature | Status: assigned
Component: contrib.staticfiles | Version: 4.2
Severity: Normal | Resolution:
Keywords: Manifest Static | Triage Stage:
Files Storage, javascript css | Someday/Maybe
html module scripts |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by blighj):
The fix for ticket #36969 has improved the situation for this. It wasn't
considered at the time but I've tested and the two examples in the
original description will now be supported.
The actual spec has moved on since this ticket was opened in 2023. see
https://github.com/tc39/proposal-import-attributes and now has broad
browser support, see https://caniuse.com/mdn-
javascript_statements_import_import_attributes.
The syntax is now `with` instead of `assert`, but due to the way the
regular expressions now work both would be covered. All that would be
needed is to prove this with some test fixtures.
The following import paths in JS files files are converted when collecting
static with ManifestStaticFilesStorage:
{{{
import sheet from './styles.css' assert { type: 'css' }; //old syntax
import sheet from './styles.css' with { type: 'css' }; // current
syntax
}}}
However there is now a dynamic import syntax, that either didn't exist or
wasn't highlighted at the time the ticket was created, that does **not**
work.
{{{
import("foo.json", { with: { type: "json" } })
}}}
foo.json will not be replaced with the cached friendly file version. That
would require a change to the regex's for dynamic imports to capture an
optional second param. something like
{{{#!diff
- r"""(?P<matched>import\(["'](?P<url>[./].*?)["']\))""",
- """import("%(url)s")""",
+ (
+ r"""(?P<matched>import\(["'](?P<url>[./].*?)["']"""
+ r"""(?P<options>(?:\s*,[^)]*)?)\))"""
+ ),
+ """import("%(url)s"%(options)s)""",
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34563#comment:5>
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 visit
https://groups.google.com/d/msgid/django-updates/0107019ebbbb2b21-ca70f859-5c5d-499b-8dca-98c530dfbffe-000000%40eu-central-1.amazonses.com.