Opened 3 years ago
Last modified 12 months ago
#33353 closed Bug
Can't collect static files if don't have vendor's JavaScript source map files — at Version 9
Reported by: | Michael | Owned by: | nobody |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 4.0 |
Severity: | Release blocker | Keywords: | manifeststatic storage |
Cc: | Adam Johnson | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Some django packages include JavaScript files, but not the sourcemaps, e.g. django-json-widget
see: https://github.com/jmrivas86/django-json-widget/issues/63
Django version 4 introduces a new features of adjusting the URLs of these source map urls. Unfortunately if one does not have these source maps, its generates an error and stops. This seems unncessary that one can't create a release in production due to an unused third party file.
Altohugh I think it should only print a warning, as dicussed below people feel its worthwhile to keep this breaking change. Can we at least make it only raise an error if settings.DEBUG == True
. That way in production where the sourcemaps are used less, its okay.
Alternatively/Additionally, could there be a settings.SOURCEMAP_EXCEPTION
etc that allows one to turn off this new break change?
Change History (9)
comment:1 by , 3 years ago
Type: | Uncategorized → Bug |
---|
follow-up: 5 comment:2 by , 3 years ago
Cc: | added |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Summary: | Can't collect static files if don't have vendor's Javascript source map files → Can't collect static files if don't have vendor's JavaScript source map files |
comment:3 by , 3 years ago
I agree with Mariusz. From Django's perspective, it's the same as having a CSS file that references a missing font. Both are missing references and potentially a mistake! Even if you left the source map line in, the browser devtools will request it and hit a 404, and show you an error.
If you don't want the source map, delete the source map reference from the vendored file.
However its very likely that one does not have this source map files for the vendor libraries (probably only the vendor uses them).
This is just a difference in approach/opinion. I use source maps everywhere and I know many developers do too.
comment:4 by , 3 years ago
Resolution: | invalid |
---|---|
Status: | closed → new |
I updated the original issue.
Could we please at least add a settings options to allow one to disable this new behaviour that breaks quite a few packages?
For example using django-json-widget
, uses some javascript files. And contry to stated above, it does not come with the sourcemaps, and one can't collectstatic.
comment:5 by , 3 years ago
Replying to Mariusz Felisiak:
As far as I'm aware, if you use 3rd-party libraries which have JavaScript source map references then you should also have them. A minified JavaScript file shouldn't contain source map references if
map
is not provided by the vendor. I hope that makes sense.
Although this makes sense, and they "should", it does not mean that they do. One has no control over source of third party packages, which do often do not include the source maps, e.g. django-json-widget
. This is a breaking change, see: https://github.com/jmrivas86/django-json-widget/issues/63
comment:6 by , 3 years ago
Description: | modified (diff) |
---|
comment:7 by , 3 years ago
Description: | modified (diff) |
---|
comment:8 by , 3 years ago
Description: | modified (diff) |
---|
comment:9 by , 3 years ago
Description: | modified (diff) |
---|
As far as I'm aware, if you use 3rd-party libraries which have JavaScript source map references then you should also have them. A minified JavaScript file shouldn't contain source map references if
map
is not provided by the vendor. I hope that makes sense.