ember-cli / ember-cli/broccoli-terser-sourcemap

improve support of malformed/missing/broken sourcemaps

Open
#23 14 comments 1 reaction 1 assignee Claimed by @stefanpenner View on GitHub
bug
Dominant language
JavaScript
Stars
10
Forks
33
PR merge metrics
No merged PRs in 30d

Description

transplanted from : https://github.com/ember-cli/ember-cli-uglify/issues/4#issuecomment-180601581

---

@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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.