#36969: collectstatic post-processing with support_js_module_import_aggregation
breaks on certain javascript files
-------------------------------------+------------------------------------
Reporter: blighj | Owner: blighj
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 6.0
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
-------------------------------------+------------------------------------
Old 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
>
> 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.
New 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
To my mind any failure is a bug, where potentially the only viable
solution for some failures is a lexer/parser as proposed by Adam in the
thrid ticket linked. Which could merit a DEP for a bug!
In the meantime another addition to ignore strings the same way comments
are ignored will help reduce these cases further.
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.
--
Comment (by blighj):
Replying to [comment:15 Jacob Walls]:
> Sounds promising, happy to see it! Will you include a link to your
benchmarK?
I've done some LLM work to make my hand crafted benchmark scripts a bit
more reproduceable. I've done a write up:
https://github.com/blighj/django-manifeststaticfiles-enhanced/wiki
/collectstatic-benchmark
The output is published on github.io
https://blighj.github.io/experiments/collectstatic_benchmark.html
The code is at https://github.com/blighj/django-manifeststaticfiles-
enhanced/tree/main/benchmarks
What it shows is that the previous ignore comment block fix solved the
bulk of the problems and the PR associated with this ticket would get that
benchmark to near 100%
--
Ticket URL: <https://code.djangoproject.com/ticket/36969#comment:19>
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/0107019eabb9b217-46e0a6df-e468-42d3-8636-d7d82ebf9cd5-000000%40eu-central-1.amazonses.com.