-
Notifications
You must be signed in to change notification settings - Fork 154
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
Fix sourcemap corruption - use composite map from UglifyJS #362
base: master
Are you sure you want to change the base?
Conversation
@terinjokes Can we get this PR merged? I've been using my fork in a number of projects with this fix, and all has been as good as before or better =). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't remove testdouble from the tests, but fill free to remove sourcemap logic that's in them.
var td = require('testdouble'); | ||
var minify = require('../lib/minify'); | ||
// Use actual UglifyJS so we are validating that the final sourcemap is indeed merged | ||
var uglify = require('uglify-js'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't going to be stable across versions.
I'm not quite sure what you mean? It seems like in that test all
This is a simple enough single line of code being minified that I would expect it to be stable, but if we can find a counter example, the test could be made more robust by using a module that parses source maps into something human readable and asserting on some heuristic checks that there are multiple mappings from a single line going back to multiple lines in multiple files. |
UglifyJS makes no promises on the identifiers it uses when minifying. |
Of course! Luckily the identifiers are not included in the map, only the offsets. In general, as long as the two identifiers it chooses are both single character (pretty much guaranteed if it's doing it's job), it'll be the same map. That being said, the only identifiers in the code I'm including in the test are globally-scoped, which Uglify must not rename. Anyway, just to get on the same page, I'd really like it if |
I'd prefer tests not call out to UglifyJS. It's out of scope for this project to ensure we are seeing a specific byte pattern from them. In fact, in the next major version of this project, we're unlikely to be depending on UglifyJS at all, and users will expected to provide their own (like a few other Gulp plugins). If UglifyJS, or a fork, make another breaking change, that's going to be on them. You can make that change, or I can do so when merging the rest. Thanks for digging into this and sending a PR. |
Okay, got it. For the next version, that sounds slightly error prone, since presumably the caller would need to inform you (or know and handle themselves) whether or not the underlying minifier is outputting sourcemaps that are relative to the supplied code or relative to the original, to know whether or not to call Anyway, that's neither here nor there... if you want to make the change while merging, that sounds good, I am completely unfamiliar with test double, might take me a bit to figure it out, but I could get to it on Monday if you don't have time =). |
Conversation and rational at: #236 (comment)
Fixes #236