You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that /# is now interpreted as a regular expression, not as a comment, which causes the call to eval() to fail, because it's not a valid regex:
We encounter a related problem: we use the numjs library and the source mapping URL rewrites introduced in fd1c033 (#808) break its JavaScript file, both the regular one and the minified version: On line 17784 of numjs sources have:
var sourceURL = '//# sourceURL=' +
This gets replaced by django-pipeline with
var sourceURL = '//# sourceURL=../../libs/numjs/' +
In the minified version, which we usually use, a second problem arises in addition to that, which results in breaking the whole library. django-pipeline replaces
var n=o("path"),e=o("./read"),t=n.join(n.resolve(r),"./data");
with
var n=o("path"),e=o("./read"),t=n.join(n.resolve(r),"../../data");
This is probably due to the first match of sourceURL and everyting being on a single line.
My configuration for this package in django-pipeline looks like this:
Is there a way of fixing this without downgrading to 3.0.0 (because we want to e.g. use new Django versions)?
Maybe it would be helpful if this rewriting can be enabled/disabled per package or at least skip sourceURL assignments that are inside quotes (i.e. are a string)?
tomka
added a commit
to catmaid/CATMAID
that referenced
this issue
Jan 22, 2025
Django-pipeline rewrites relative URLs for source map files since v3.1.
This leads to problems with our NumJS version, because rewriting
relative paths breaks the module loading logic of NumJS.
Currently, this rewriting can't be disabled and there didn't seem a good
way to monkey-patch django-pipeline. Therefore, we adapt the NumJS
source file to add a space in order to trick django-pipeline. This
commit changes:
var sourceURL = '//# sourceURL=' +
to
var sourceURL = '// # sourceURL=' +
This doesn't break our usage of NumJS and avoids the rewriting, because
its regular expression matches on "//# sourceURL".
This GitHub comment explains this in more detail:
jazzband/django-pipeline#812 (comment)
Version 3.1.0 of django-pipeline looks like it is producing JS which isn't valid.
My input JS file has code like this (initial contents of
eval()
removed for simplicity):That is being transformed by django-pipeline into this (note the
/# sourceURL
at the end should be//#
but is now/#
):The problem is that
/#
is now interpreted as a regular expression, not as a comment, which causes the call toeval()
to fail, because it's not a valid regex:Reverting to 3.0.0 fixes the problem.
The text was updated successfully, but these errors were encountered: