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
Cherry-pick terser to webpack 4 #8392
Conversation
Some history: * `uglifyjs-webpack-plugin` < v1.0 used the minifier `uglify-js` * however `uglify-js` does not support ES6, which resulted in a fork called `uglify-es` that was developed in the `uglify-js` repository, but under the `harmony` branch * `uglifyjs-webpack-plugin` v1.x switched to `uglify-es` for ES6 support * however `uglify-es` stopped being maintained: mishoo/UglifyJS#3156 (comment) * which led to a fork called `terser` that has incorporated all of the unmerged PRs and will be where all new development occurs: https://github.com/fabiosantoscode/terser * `terser-webpack-plugin` was created, which is the `terser` equivalent of `uglifyjs-webpack-plugin`: https://github.com/webpack-contrib/terser-webpack-plugin * `uglifyjs-webpack-plugin` v2.x will be switching back to `uglify-js`, so any project that needs to support ES6 now needs to switch to `terser-webpack-plugin`. Fixes #7923.
For maintainers only:
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
Be aware that |
We do not allow to pass these options when using the defaults. So that should not be a problem. To pass these options you have to override the defaults and include the terser/uglify plugin manually. The different warning messages may be a small breaking change for some users, but we have to accept this... |
Thanks |
Let's hope this doesn't break too much... Ready for some terser bug reports @kzc? This brings a lot of new users to terser... |
I've created an issue to document this in webpack/webpack.js.org. |
Replaces the minifier we're using on prod builds from `uglify-js` to `terser`. Terser is a more updated replacement for UglifyJS. Webpack 4 switched to using it as the default minifier in Nov 2018 (webpack/webpack#8392). The reasons we'd want to switch: * Unblocks future updates to typescript output target; uglify only supports up to ES5 javascript, Terser supports more recent javascript as input * Closer to the "normal" webpack happy path * As of recently, [more widely used (with webpack)](https://www.npmtrends.com/uglifyjs-webpack-plugin-vs-terser-webpack-plugin) It is essentially a drop in replacement; we expect no customer-visible changes as a result of this update.
This PR #8036 was cherry-picked.
Motivation: #8350 (comment)
Issue: #8350
What kind of change does this PR introduce?
Bugfix.
Did you add tests for your changes?
N/A.
Does this PR introduce a breaking change?
No.
What needs to be documented once your changes are merged?
Default for the
optimization.minimizers
option need to be changed to TerserWebpackPlugin.