terser-webpack-plugin: TypeError: Cannot read property 'javascript' of undefined
- Operating System: OS X 10.15.7
- Node Version: 12.16.0
- NPM Version: 6.14.8
- webpack Version: 5.1.2
- terser-webpack-plugin Version: 5.0.0
Expected Behavior
Build doesn’t fail
Actual Behavior
Build fails with : TypeError: Cannot read property ‘javascript’ of undefined at /node_modules/terser-webpack-plugin/dist/index.js:366:38
Code
My config :
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
output: {
comments: false
},
},
extractComments: false
}),
]
}
How Do We Reproduce?
Update version of webpack & terser to latest then make build of assets of project : https://github.com/oguilleux/webpack-gulp-wordpress-starter-theme
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 21
- Comments: 19 (8 by maintainers)
Commits related to this issue
- Pin terser plugin until issue is resolved Issue thread: https://github.com/webpack-contrib/terser-webpack-plugin/issues/335 — committed to isle-project/isle-editor by Planeshifter 4 years ago
- Update to use terser 4 and remove deprecated webpack uglify minifer per https://github.com/webpack-contrib/terser-webpack-plugin/issues/335#issuecomment-709716106 — committed to JackHowa/meta-store-frontend by JackHowa 4 years ago
Because
terser-webpack-plugin@5
doesn’t have compatibility with webpack@4, please read readme, don’t understand why it is so hardencountered the same problem, i am building my typescript babel react project.
i use v4.2.3 of terser-webpack-plugin, it builds successfully
@Tofandel seriously? Please read the CHANGELOG
@Jerry-zhk why need to spam?
@oguilleux https://github.com/oguilleux/webpack-gulp-wordpress-starter-theme/blob/master/package.json#L66 really?
This is by far one of the funniest GitHub issues i’ve seen.
webpack-stream
useswebpack@4
, so you got this problem https://github.com/shama/webpack-stream/blob/master/package.json#L37, sorry nothing to fix here, webpack should be in peer deps insidewebpack-stream
, not independencies
@alexander-akait you are getting a lot of thumbs down because you are not being pleasant in your responses. Instead of getting exasperated the first time someone asks a question and saying, “Seriously?! RTFM!!!” try exercising a little more patience and empathy. I understand you are dealing with a lot more than just this one GitHub issue, but one comment here isn’t spam. I’m trying to be nothing but honest and helpful here as I’ve sent my fair share of online messages that I regret. ✌
If you are using webpack v5 or above you do not need to install this plugin. Webpack v5 comes with the latest terser-webpack-plugin out of the box. Using Webpack v4, you have to install terser-webpack-plugin v4.
@oguilleux yep, we are working on it, release with fix will be today/tomorrow
This happenend to me with Webpack5.15.0 and Terser5.5.1 Problem was that I only did
yarn add -D wepack
and forgot to doyarn add -D webpack-cli
not necessarily related to webpack4.