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

Cherry-pick terser to webpack 4 #8392

Merged
merged 3 commits into from Nov 19, 2018
Merged

Cherry-pick terser to webpack 4 #8392

merged 3 commits into from Nov 19, 2018

Conversation

vkrol
Copy link
Contributor

@vkrol vkrol commented Nov 18, 2018

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.

edmorley and others added 3 commits November 18, 2018 22:56
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.
@webpack-bot
Copy link
Contributor

webpack-bot commented Nov 18, 2018

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@vkrol vkrol changed the title Cherry pick terser to webpack 4 Cherry-pick terser to webpack 4 Nov 18, 2018
@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@kzc
Copy link

kzc commented Nov 18, 2018

Be aware that terser-webpack-plugin has an API incompatibility with uglifyjs-webpack-plugin: terserOptions versus uglifyOptions. This may affect some webpack users.

#8350 (comment)

@sokra
Copy link
Member

sokra commented Nov 19, 2018

Be aware that terser-webpack-plugin has an API incompatibility with uglifyjs-webpack-plugin: terserOptions versus uglifyOptions. This may affect some webpack users.

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...

@sokra sokra merged commit e1df721 into webpack:master Nov 19, 2018
@sokra
Copy link
Member

sokra commented Nov 19, 2018

Thanks

@sokra
Copy link
Member

sokra commented Nov 19, 2018

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...

@webpack-bot
Copy link
Contributor

I've created an issue to document this in webpack/webpack.js.org.

dbjorge added a commit to microsoft/accessibility-insights-web that referenced this pull request Aug 13, 2019
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.
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.

None yet

5 participants