-
Notifications
You must be signed in to change notification settings - Fork 155
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
gulp-uglify generates source maps but mapping is incorrect #236
Comments
Right now my order is something like the following and I'm also experiencing this. Running w/o uglify allows for it to map properly.
|
I just rolled back to v1.5.4 and this is now working for me. |
I am also getting issue with sourcemap generated. with both 2.0 and 1.5.4 also. |
@pinalbhatt Posting what your chain looks like can help diagnose the problem. |
I am also having this issue. The following does not work with gulp-uglify 2.1.2, and problematic sourcemaps are produced:
However, as per @g5codyswartz's suggestion, it works fine with gulp-uglify 1.5.4
|
Ran into this with 3.0.0, I had to set |
Thanks, everyone in this thread. 1.5.4 works. |
I think I am still having this problem, but there seem to be a lot of people complaining about sourcemaps without any solutions. The problem I am having is that the sourcemaps are generated, but if I add a console.error on a certain line the line number in the browser console is wrong. Which results in being sent to the wrong line in the file. I also checked the file itself and that actually perfectly matches the development file, so not sure why browsers are mapped to the wrong line. I am using gulp-uglify in combination with gulp-concat and disabling gulp-uglify does solve the problem, but ofcourse that is no solution. Besides both should support sourcemaps just fine according to the documentation. I already tried all other suggested sollutions in other issues and this issue and nothing seems to help. I tested in both Firefox and Chrome and both had the same issue. Is there any update or solution for this? |
Spent a bunch of time looking into this, and it appears the latest [email protected] + [email protected] is applying the sourceMap mapping twice - if I replace |
IIRC this is supposed to be fine, but there's probably enough ambiguity in the sourcemap spec to cause problems. I can apply that change, but need to figure out a good way to test this so there's no regression. |
It's seems like it can't possibly be fine. If map A maps lines 10:5 and 8:4 and map B does a (relative) map of 5:4 and 4:2, the output must be 10:4 and 8:2, but if that relative map is applied a second time, the output ends up being along the lines of mapping lines 10:2, 8:2 and 5:4, 2 of 3 of which are not valid. In this case, it's applying what should be an absolute map (mapping all the way back to the original source) as a relative map. Judging from another comment in that file, it makes me think that at one point uglify-js was not generating the absolute mapping, but a relative mapping (which is what vinyl-source-map-apply expects). I am quite unfamiliar with the low-level stuff and the spec, so I certainly could be confused about something in here though =). |
What I meant was the sourcemap tool should have enough information to know that it has the output mapping as input, not a relative mapping, and act accordingly. I haven't thought about the broken state of sourcemaps in so long it's possible I'm wrong. I recall needing to do this to get the sourcmaps output by UglifyJS to attach to the sourcemaps of the input, particularly in cases where the original code was written in a language compiled to JS (like coffeescript). Without applying the sourcemaps you wouldn't see the original code in the browser. |
I think All that being said, the change I mentioned definitely fixed my case for piping |
I'm guessing UglifyJS changed their behavior at some point, you can find older issues where that definitely wasn't the case. |
Good find @Jimbly
|
Ah, figured out why it was mysteriously working in my other project: When doing babel -> browserify ->gulp-uglify, the browserify step is "renaming" the file, so in that case, the Conclusion: Since |
I have this task to generate bundled & minified JavaScript file:
Looks ok:
.min.js
gets mangled etc and sourcemaps are generated. But unfortunatelly debugging is not possible. Mapping is incorrect - stepping through the code / locals is broken.gulp-uglify
seems to be the culprit because if I remove it from the the task, mapping works (with ngAnnotations in place as well as with babel transformation). Any idea that's going on? User versions are:The text was updated successfully, but these errors were encountered: