Skip to content
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

Merged
merged 2 commits into from
Jul 10, 2017

Conversation

fusion2004
Copy link
Contributor

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.

index.js Outdated
enableSourcemaps: this.enableSourcemaps()
compress: this.options.compress,
mangle: this.options.mangle,
sourceMap: this.enableSourcemaps() ? sourceMapOptions : false
Copy link
Contributor Author

@fusion2004 fusion2004 Jun 9, 2017

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?

Copy link
Collaborator

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)));
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

@Turbo87 Turbo87 merged commit ed831cf into ember-cli:master Jul 10, 2017
@Turbo87
Copy link
Member

Turbo87 commented Jul 10, 2017

released as v2.0.0-beta.2

@Turbo87 Turbo87 mentioned this pull request Jul 10, 2017
@fusion2004 fusion2004 deleted the upstream-uglify-es branch July 10, 2017 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants