-
-
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
Use uglify-es instead of uglify-js #47
Conversation
index.js
Outdated
enableSourcemaps: this.enableSourcemaps() | ||
compress: this.options.compress, | ||
mangle: this.options.mangle, | ||
sourceMap: this.enableSourcemaps() ? sourceMapOptions : false |
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.
Looking back at this, I'm not sure if this is what we want to do. It looks like I was trying to keep the input the options the same and map them to the new options that are in UglifyJS 3. Of course, now you can't access all of the options anymore from your ember-cli-build config.
Should I change this to bring all the options over again, with the expectation that anyone upgrading their ember-cli-uglify/broccoli-uglify-sourcemap would need to update their config?
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.
ah this makes stuff a tad tricky.
I suspect the first step will be a major version bump of this library. But we would also like to include it in new ember-cli blueprints. So we may need to explore potential upgrade pains/and come up with a gentle upgrade plan if it is too painful.
Thoughts?
index.js
Outdated
var url = srcURL.getFrom(src); | ||
opts.inSourceMap = path.join(path.dirname(inFile), url); | ||
origSourcesContent = JSON.parse(fs.readFileSync(opts.inSourceMap)).sourcesContent; | ||
opts.sourceMap.content = JSON.parse(fs.readFileSync(path.join(path.dirname(inFile), url))); |
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 was somewhat of a guess as to what this code was supposed to do. As far as I can tell, the origSourcesContent
variable is never used in the current master branch?
index.js
Outdated
} | ||
|
||
try { | ||
var start = new Date(); | ||
debug('[starting]: %s %dKB', relativePath, (src.length / 1000)); | ||
var result = UglifyJS.minify(src, merge(opts, this.options)); | ||
var result = UglifyJS.minify(src, opts, this.options); | ||
if (result.error) throw result.error; |
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.
UglifyJS 3 no longer throws an error for us, and instead expects us to throw it ourselves: This is documented at the end of the API Reference section of the readme.
a8e2035
to
861575f
Compare
released as |
This is my attempt at changing this to use the latest 3.x uglify-es, which has support for ES2015. This addresses #46.
The expected test sourcemap changes are a copy & paste of the output, and I'm not certain if they are correct. From testing this on our ember apps, it looks like I get an output that makes sense when attempting to debug things in Chrome's dev tools.