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

Switch from uglifyjs-webpack-plugin to terser-webpack-plugin #8036

Merged
merged 3 commits into from Sep 16, 2018

Conversation

Projects
None yet
4 participants
@edmorley
Copy link
Member

edmorley commented Sep 15, 2018

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
  • which led to a fork called terser that has incorporated all of the unmerged PRs and will be where all new development occurs
  • terser-webpack-plugin was created, which is the terser equivalent of uglifyjs-webpack-plugin
  • uglifyjs-webpack-plugin v2.x has switched back to uglify-js, so any project that needs to support ES6 now needs to switch to terser-webpack-plugin instead.

Fixes #7923.

What kind of change does this PR introduce?

Bugfix (since terser includes many correctness fixes) but also breaking change (see below).

Did you add tests for your changes?

There are existing tests which have been updated for the plugin name change.

Does this PR introduce a breaking change?

Yes. The new plugin:

  • requires the minifier options to be passed under terserOptions, rather than the previous uglifyOptions.
  • has changed the method signature that should be used when specifying a warningsFilter function.

What needs to be documented once your changes are merged?

@webpack-bot

This comment has been minimized.

Copy link

webpack-bot commented Sep 15, 2018

For maintainers only:

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

This comment has been minimized.

Copy link

webpack-bot commented Sep 15, 2018

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

WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction4 [./a.js:6,0] in bundle.js

WARNING in UglifyJs Plugin: Dropping unused function someUnRemoteUsedFunction5 [./a.js:7,0] in bundle.js"
[2] (webpack)/buildin/module.js 497 bytes {0} [built]"

This comment has been minimized.

@sokra

sokra Sep 15, 2018

Member

Could you rename test/statsCases/warnings-uglifyjs too?

This comment has been minimized.

@sokra

sokra Sep 15, 2018

Member

I also wonder why this snapshot differs?

This comment has been minimized.

@edmorley

edmorley Sep 15, 2018

Member

I also wonder why this snapshot differs?

It seems that the warnings message format is slightly different between the two plugins:
https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/v1.3.0/src/index.js#L121
https://github.com/webpack-contrib/terser-webpack-plugin/blob/v1.1.0/src/index.js#L150

@evilebottnawi is this expected?

This comment has been minimized.

@evilebottnawi
@webpack-bot

This comment has been minimized.

Copy link

webpack-bot commented Sep 15, 2018

@edmorley Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

edmorley added some commits Sep 9, 2018

Switch from uglifyjs-webpack-plugin to terser-webpack-plugin
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/UglifyJS2#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.

@edmorley edmorley force-pushed the edmorley:use-terser-webpack-plugin branch from 75dcb90 to dd19dc0 Sep 15, 2018

@webpack-bot webpack-bot added PR: CI-ok and removed PR: conflict labels Sep 15, 2018

@sokra sokra added this to Yes (and in progress) in webpack 5 Sep 16, 2018

@sokra

sokra approved these changes Sep 16, 2018

@edmorley

This comment has been minimized.

Copy link
Member

edmorley commented Sep 16, 2018

Ah good spot on the warningsFilter signature change - thank you for adding a fix.

@sokra sokra merged commit b7128d8 into webpack:next Sep 16, 2018

11 of 12 checks passed

codecov/changes/integration 1 file has unexpected coverage changes not visible in diff.
Details
codecov/changes/basic No unexpected coverage changes found.
Details
codecov/changes/unit No unexpected coverage changes found.
Details
codecov/patch/integration 100% of diff hit (target 90%)
Details
codecov/patch/unit Coverage not affected when comparing 97ed999...a94d043
Details
codecov/project/basic 100% remains the same compared to 97ed999
Details
codecov/project/integration Absolute coverage decreased by -0.01% but relative coverage increased by +8.6% compared to 97ed999
Details
codecov/project/unit 35.61% (target 0%)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details
security/snyk - package.json (sokra) No new issues
Details
@webpack-bot

This comment has been minimized.

Copy link

webpack-bot commented Sep 16, 2018

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

@sokra

This comment has been minimized.

Copy link
Member

sokra commented Sep 16, 2018

Thanks

@sokra sokra moved this from Yes (and in progress) to Done in webpack 5 Sep 16, 2018

@edmorley edmorley deleted the edmorley:use-terser-webpack-plugin branch Sep 16, 2018

edmorley added a commit to edmorley/webpack.js.org that referenced this pull request Sep 16, 2018

docs(config): Replace UglifyJSPlugin references with TerserPlugin
Since the default `options.minimizer` is now `terser-webpack-plugin`:
webpack/webpack#8036

I've also updated the custom `minimizer` example to include all of the
default options, to reduce the chance people forget to enable them.

Fixes webpack#2520.

edmorley added a commit to edmorley/webpack.js.org that referenced this pull request Sep 16, 2018

docs(config): Replace UglifyJSPlugin references with TerserPlugin
Since the default `options.minimizer` is now `terser-webpack-plugin`:
webpack/webpack#8036

I've also:
* updated the custom `minimizer` example to include all of the default
  options, to reduce the chance people forget to enable them.
* removed the `optimize/UglifyJsPlugin` reference, since it's no
  longer included in the webpack repository.
* removed the "Here are a few more popular ones" mention, since it's
  not accurate (they aren't more popular).
* removed manual plugin configuration from `configuration-languages.md`
  since the defaults for `minimizer` make it unnecessary.

Fixes webpack#2520.

montogeek added a commit to webpack/webpack.js.org that referenced this pull request Sep 18, 2018

docs(config): Replace UglifyJSPlugin references with TerserPlugin (#2522
)

* docs(config): Replace UglifyJSPlugin references with TerserPlugin

Since the default `options.minimizer` is now `terser-webpack-plugin`:
webpack/webpack#8036

I've also:
* updated the custom `minimizer` example to include all of the default
  options, to reduce the chance people forget to enable them.
* removed the `optimize/UglifyJsPlugin` reference, since it's no
  longer included in the webpack repository.
* removed the "Here are a few more popular ones" mention, since it's
  not accurate (they aren't more popular).
* removed manual plugin configuration from `configuration-languages.md`
  since the defaults for `minimizer` make it unnecessary.

Fixes #2520.

* Address review comment

@pi0 pi0 referenced this pull request Sep 20, 2018

Merged

hotfix: use `terser-webpack-plugin` #3928

0 of 7 tasks complete

clarkdo added a commit to nuxt/nuxt.js that referenced this pull request Sep 20, 2018

hotfix: use `terser-webpack-plugin` (#3928)
<!--- Provide a general summary of your changes in the title above -->

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)


## Description
Webpack requires `uglifyjs-webpack-plugin@1.x`. thus `uglifyjs-webpack-plugin@2.x` may not resolve correctly. Also, the webpack team decided to go with `terser-webpack-plugin` (webpack/webpack#8036).


## Checklist:
<!--- Put an `x` in all the boxes that apply. -->
<!--- If your change requires a documentation PR, please link it appropriately -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly. (PR: #)
- [ ] I have added tests to cover my changes (if not applicable, please state why)
- [ ] All new and existing tests passed.

@michael-ciniawsky michael-ciniawsky removed this from Done in webpack 5 Oct 1, 2018

jakemarsden added a commit to jakemarsden/aikido-track that referenced this pull request Oct 11, 2018

Replace uglifyjs-webpack-plugin with terser-webpack-plugin
For the same reasons as webpack/webpack#8036
Webpack will switch to terser by default for 5.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment