-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve support of malformed/missing/broken sourcemaps #23
Comments
Strange, I am pretty sure at the end works. I believe this test even illustrates that https://github.com/ef4/broccoli-uglify-sourcemap/blob/master/test/fixtures/inside/with-upstream-sourcemap.js#L22 |
Try my example, you can see clearly that if you manually edit |
(Which indicates that the sourcemap itself isn't malformed / broken / missing) |
(Though there should be a story for handling the case of missing / broken / malformed as well) |
Interesting, sounds like we have 2 separate things:
@johnnyshields if you have time to (at the least) provide a failing test on this repo, it will be something I suspect I can look at this weekend and try to sort out. That would just give me a good run-way. (unless you are interested in taking it to completion, or iterating) |
EDIT: Ignore this comment and see next one
|
@stefanpenner OK I believe I've gotten close to the issue. I've analyzed the intermediate \\ vendor.map -- GOOD when sprintf.js has comment at beginning
{"version":3,"sources":[...,"bower_components/ember-data/ember-data.prod.js","bower_components/sprintf/dist/sprintf.min.js","bower_components/bootstrap/dist/js/bootstrap.js",... However, when the magic comment comes at end of the file, I see this: \\ vendor.map -- BAD when sprintf.js has comment at end
{"version":3,"sources":[...,"bower_components/ember-data/ember-data.prod.js","../src/sprintf.js","bower_components/bootstrap/dist/js/bootstrap.js",... So the difference is in GOOD version You can reproduce the same thing by logging the I believe this is enough information to fix the issue; I think the problem is NOT in broccoli-uglify-sourcemap but in whatever lib generates the concatenated Unfortunately I won't have time this week to investigate this further or write a test case, but I believe that this information should be enough for you to nail down the exact issue. |
@johnnyshields it also seems like min.js is lost in the second version. |
You're right, when magic comment at the top it's the same as if it were not there all, i.e. Ember CLI uses the Moreover I'm not sure there's any issue with the relative paths, because if I delete the
I validated |
Added PR w/ test case for this issue here: #24 |
@stefanpenner I have another lead. It seems like the vendor.js / map generated during Ember CLI compilation and fed into broccoli-uglify-sourcemap is invalid according to sourcemaps.io, and moreover the validation error corresponds to the error we see in Ember. Note that the individual sourcemaps which are compiled into the build are not invalid themselves, so its reasonable to think something is incorrect during the concatenation causing the output to be malformed. |
@johnnyshields awesome thanks for the continued deep dive. As my work also wants this to work ideally, I can likely take some time this week during the day to try and sort this out. |
Update: I've made a test here: broccolijs/broccoli-concat#50 for what I believe to be the root cause--broccoli-concat is generating an invalid vendor.js/vendor.map which broccoli-uglify-sourcemap chokes on later in the build process. |
I found another case is that some third-party libraries have Base64 sourcemap embedded in the source file which also crash the build process. To reproduce, you can run |
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:
If a lib declares the magic comment at the END of its file, the following happens:
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 thesprintf.js
to have the magic comment at the beginning, everything works.The text was updated successfully, but these errors were encountered: