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 7

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 Michael)

Some django packages include JavaScript files, and no the sourcemaps.

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 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 that breaks third part packages. 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.SOURCEMAPE_EXCEPTION etc that allows one to turn off this new break change?

Change History (7)

comment:1 by Michael, 3 years ago

Type: UncategorizedBug

comment:2 by Mariusz Felisiak, 3 years ago

Cc: Adam Johnson added
Resolution: invalid
Status: newclosed
Summary: Can't collect static files if don't have vendor's Javascript source map filesCan't collect static files if don't have vendor's JavaScript source map files

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.

comment:3 by Adam Johnson, 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 Michael, 3 years ago

Resolution: invalid
Status: closednew

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.

Last edited 3 years ago by Michael (previous) (diff)

in reply to:  2 comment:5 by Michael, 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

Last edited 3 years ago by Michael (previous) (diff)

comment:6 by Michael, 3 years ago

Description: modified (diff)

comment:7 by Michael, 3 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top