terser-webpack-plugin: Terser v3.16.0 breaks terser-webpack-plugin
The latest terser update (released an hour ago) breaks this plugin.
- Operating System:
- Node Version: 10.12.0
- NPM Version: 6.4.1
- webpack Version: 4.29.0
- terser-webpack-plugin Version: 1.2.1
Expected Behavior
Terser to minify my code
Actual Behavior
ERROR in js/main.6e4faa1e7d31caf0fa3b.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/<path>/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
How Do We Reproduce?
Delete yarn.lock
Install terser-webpack-plugin and try to run a production build where the plugin is called
workaround
As a workaround for now if you use yarn you can add a resolution to a fixed terser version. Delete yarn.lock first and node_modules
Example (in your package.json)
"resolutions": {
"terser": "3.14.1"
}
For npm try the suggestion by @odedi
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 160
- Comments: 54 (4 by maintainers)
Commits related to this issue
- [skip ci] try fixing bug on nuxt build with webpack. solution set a resolution: https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 — committed to valeriosillari/zitronenstrasse by valeriosillari 5 years ago
- lock "webpack/terser-webpack-plugin/terser" to "3.14.1" https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- Fix broken builds See https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 — committed to kasparsd/burti by kasparsd 5 years ago
- lock "webpack/terser-webpack-plugin/terser" to "3.14.1" https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 — committed to vladimiry/ElectronMail by vladimiry 5 years ago
- fix(dependencies): install terser@3.41.1 (see https://github.com/webpack-contrib/terser-webpack-plugin/issues/66) — committed to bootstrap-styled/rsg-components by deleted user 5 years ago
- fix(dependencies): install terser@3.41.1 (see https://github.com/webpack-contrib/terser-webpack-plugin/issues/66) — committed to bootstrap-styled/bootstrap-styled by deleted user 5 years ago
- fix(dependencies): install terser@3.41.1 (see https://github.com/webpack-contrib/terser-webpack-plugin/issues/66) — committed to bootstrap-styled/v4 by deleted user 5 years ago
- chore(release): 2.4.9 [skip ci] ## [2.4.9](https://github.com/bootstrap-styled/bootstrap-styled/compare/v2.4.8...v2.4.9) (2019-02-02) ### Bug Fixes * **dependencies:** install terser@3.41.1 (see ht... — committed to bootstrap-styled/bootstrap-styled by semantic-release-bot 5 years ago
- chore(release): 1.1.7 [skip ci] ## [1.1.7](https://github.com/bootstrap-styled/rsg-components/compare/v1.1.6...v1.1.7) (2019-02-02) ### Bug Fixes * **dependencies:** fix terser ([871ed46](https://g... — committed to bootstrap-styled/rsg-components by semantic-release-bot 5 years ago
- chore(release): 3.0.2 [skip ci] ## [3.0.2](https://github.com/bootstrap-styled/v4/compare/v3.0.1...v3.0.2) (2019-02-02) ### Bug Fixes * **dependencies:** fix terser ([63d5f15](https://github.com/bo... — committed to bootstrap-styled/v4 by semantic-release-bot 5 years ago
- add package-lock.json to fix(?) failing builds (https://github.com/webpack-contrib/terser-webpack-plugin/issues/66) — committed to rthaut/YouTubePopoutPlayer by rthaut 5 years ago
- add package-lock.json to fix(?) failing builds (https://github.com/webpack-contrib/terser-webpack-plugin/issues/66) — committed to rthaut/YouTubePopoutPlayer by rthaut 5 years ago
- fix: add resolution for downstream dependency https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 https://github.com/terser-js/terser/pull/254 — committed to remirror/remirror by ifiokjr 5 years ago
- Fix build: downgrade to terser `3.14.1` Terser 3.16.0 has a bug which causes the webclient build to fail: https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 As soon as the bug is fix... — committed to dmx-systems/dmx-platform by jri 5 years ago
- [Client/pkg] Fix minfication (ref: https://github.com/webpack-contrib/terser-webpack-plugin/issues/66) — committed to codeschluss/wuppngo by schlusslicht 5 years ago
- Hotfix: Downgrade terser to 3.14.1 see https://github.com/webpack-contrib/terser-webpack-plugin/issues/66 — committed to emanuelschuetze/OpenSlides by emanuelschuetze 5 years ago
- fix: added support for base64url Encoded JWTs (#308) * Switched back to npm from yarn * Locked down the terser version to fix an issue with webpack closes #307 relates webpack-contrib/terser-webpack... — committed to salte-auth/salte-auth by deleted user 5 years ago
- fix: added support for base64url Encoded JWTs (#308) * Switched back to npm from yarn * Locked down the terser version to fix an issue with webpack closes #307 relates webpack-contrib/terser-webpack... — committed to salte-auth/salte-auth by deleted user 5 years ago
- Temp fix for terser error — committed to reforming-education-on-drugs/RedWebsite by jackieluc 5 years ago
- fix: added support for base64url Encoded JWTs (#308) * Switched back to npm from yarn * Locked down the terser version to fix an issue with webpack closes #307 relates webpack-contrib/terser-webpack... — committed to salte-auth/salte-auth by deleted user 5 years ago
A bug in terser 3.16 which was released hours ago.
For npm users run:
npm i terser@3.14
For yarn users: add the following field to package.json and then rerun yarn:
Solution:
npm install terser@3.14.1 --save-dev
For me it solves!I changed
_terser.default.minify
to_terser.minify
and it worksTo summarize it: Everybody that gets a CI failure on the master branch or an error on production, probably didn’t commit the lockfile. That’s not how lockfiles work. They are there to fix your dependencies, so every dependency upgrade need to be done manually** in a PR, which is reviewed and tested by CI. This way no broken release (which happen, because everyone makes mistakes) could every break your production environment or even your development workflow.
** There are also services to automate this.
For everyone using npm who can’t wait for update from terser, here is a simple (temporary) fix you can apply:
Cheers
https://github.com/rogeriochaves/npm-force-resolutions for npm
Hello guys, the same problem for me when running nuxt generate, now I fixed using @TomCosta solution
npm install terser@3.14.1 --save-dev
, so thanks. Hope this problem will be fixed in the future.Fix has been implemented: https://github.com/terser-js/terser/pull/254
https://github.com/terser-js/terser/pull/254 should address this.
Locking the dependencies is useful for libraries too as it makes the build process reproducible.
When doing the above trick, make sure to install the exact version (
--save-exact
) or else you’ll end up with a broken first level dependency:npm install terser@3.14.1 --save-dev --save-exact
And your package.json afterwards should mention:
terser: "3.14.1"
- there should be NO^
in front of the3
.@vladimiry Agree. Default exports and
module.exports
assignment were mistake.@huochunpeng the point is that
terser
made a breaking change without bumping the major version, but just v3.14.1 => v3.16.0. Besides worth taking into the account that it’s not justterser-webpack-plugin
depends onterser
but many other libraries too.@afide1 Hey, its been fixed, all you need to do is update terser-webpack-plugin to v1.2.2 +
Locking the dependencies is not that useful for libraries. You rather want to see things break in your CI and be warned about it. If you must lock your dependency to a certain dependencies, this should be the way to go.
@bendg25 look at your package-lock.json and search for “terser”. I have suggested a fix somewhere up in the comments.
@anujladia if you build something on CI servers (Travis, Gitlab, etc) using npm consider executing npm ci there instead of
npm install
.@anujladia check my suggestion, I was also with the same case. Install terser 3.14.1 locally with —save-dev, modify package-lock and specify 3.14.1 and not anything else starting with ^ for any package using it
@mdix I am not using terser library directly in my package.json. Third party libraries are using terser, so will this change help me be able to build my web app correctly?
So hopefully over a time all the developers will have https://palantir.github.io/tslint/rules/no-default-export/ / https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md rules enabled in own library-like projects.
This is also affecting Create React App. See https://github.com/facebook/create-react-app/issues/6334.
Running
npm install terser@3.14.1 --save-dev
fixed my Nuxtnpm run build
too. Thank you.@TomCosta , I literally had this issue about 15 mins ago for an ionic 4 project. Found your solution, which you posted about 10 mins ago and worked perfectly, thanks 😃
Yikes, looks like next.js is broken too 😨