Opened 85 minutes ago
#36969 new Bug
collectstatic post-processing with support_js_module_import_aggregation breaks on certain javascript files
| Reported by: | blighj | Owned by: | |
|---|---|---|---|
| Component: | contrib.staticfiles | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The regular expressions to find import/export statements in javascript can work in common cases but still have plenty of failure modes. A lot of the failures were in comments, which were getting tracked in #21080. But there will always remain others, the complexity space of javascript is more than the regexs can handle. Any code with import like statements in strings will break it for sure.
- https://code.djangoproject.com/ticket/21080#comment:26
- https://code.djangoproject.com/ticket/35371
- https://code.djangoproject.com/ticket/34322#comment:17
- https://code.djangoproject.com/ticket/32849
To my mind this is a bug, where potentially the only viable solution is a lexer/parser as proposed by Adam in the thrid ticket linked. Which could merit a DEP for a bug!
Or it might just need some sort of update to the docs to articulate Carlton's point in this comment
https://code.djangoproject.com/ticket/32319#comment:21
It's not clear the [regex approach] covers all usages, but it looks OK for common cases.
I think we need to be prepared to say where we're not going to try more complex solutions.
But let's see... 😬
In either case I think it is usefull to have one ticket that tracs all these regex failures in one place, rather than having multiple tickets that are sort of duplicates of this 'regex not working' issue..
There is the package django-manifeststaticfiles-enhanced which provides the lexer solution.