Skip to content

improve support of malformed/missing/broken sourcemaps #23

@stefanpenner

Description

@stefanpenner

transplanted from : ember-cli/ember-cli-terser#4 (comment)


@stefanpenner

Here's an updated repo which reproduces the issue: https://github.com/johnnyshields/ember-sourcemap-issue

I believe I found the problem: ember-cli-uglify requires 3rd-party bower libs to have their magic sourcemap at the BEGINNING of their source, so that Ember CLI can concatenate them like this:

//# sourceMappingURL=lib1.map
lib1.js code

lib2.js code   // this lib doesn't have a sourcemap

//# sourceMappingURL=lib3.map
lib3.js code

If a lib declares the magic comment at the END of its file, the following happens:

lib1.js code

//# sourceMappingURL=lib1.map      ember gets con
lib2.js code

Because Ember CLI evaluates the maps on the CONCATENATED file, here it apparently gets confused and thinks the source map is for lib2 when it's actually for lib1.

So, infact in the original post of this thread, select2 is not the issue--whichever JS comes BEFORE select2 is the issue, but error thrown looks like it's select2.

My sample repo uses sprintf.js as an offender which has magic comment at the end. If you manually edit the sprintf.js to have the magic comment at the beginning, everything works.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions