optimize-plugin
optimize-plugin copied to clipboard
Not a webpack bundle unhandled rejection on every chunk
Multi entry webpack 4 (latest) configuration on Node 14. It does this for every chunk
errored out during transformation Error: /Users/claudio/Projects/loom/js/404-3594367e1117c0d15bb5.js: Not a webpack bundle
at mod (/Users/claudio/Projects/loom/node_modules/optimize-plugin/dist/worker.js:203:15)
at /Users/claudio/Projects/loom/node_modules/optimize-plugin/dist/worker.js:211:9
at Array.forEach (<anonymous>)
at getWebpackModules (/Users/claudio/Projects/loom/node_modules/optimize-plugin/dist/worker.js:207:10)
at getWebpackBootstrap (/Users/claudio/Projects/loom/node_modules/optimize-plugin/dist/worker.js:85:25)
at /Users/claudio/Projects/loom/node_modules/optimize-plugin/dist/worker.js:256:29
at Array.forEach (<anonymous>)
at PluginPass.Program (/Users/claudio/Projects/loom/node_modules/optimize-plugin/dist/worker.js:255:26)
at newFn (/Users/claudio/Projects/loom/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/visitors.js:175:21)
at NodePath._call (/Users/claudio/Projects/loom/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/context.js:55:20) {
type: 'Error',
code: 'BABEL_TRANSFORM_ERROR'
}
Any pointers? 🙏
Hiya - this seems the same as the second issue mentioned in #7.
Are you able to share your Webpack configuration - in particular the mode, target and output options?
Absolutely!
{
"entry":{
...multiple entries
},
"output":{
"path":"/Users/claudio/Projects/loom/dist/webpack",
"publicPath":"https://cdn.loom.com/assets/",
"filename":"js/[name]-[contenthash].js"
},
"devtool":false,
"module":{
"rules":[...rules]
},
"optimization":{
"moduleIds":"hashed",
"splitChunks":{
"cacheGroups":{
"default":false,
"commons":{
"name":"commons",
"test":{
},
"chunks":"all",
"minChunks":3
}
}
},
},
"plugins":[...plugins],
"resolve":{...aliases only},
"mode":"production"
}
babel.config contains preset/react and preset/env with no modules nor target options set.
Awesome, thanks for this. I will try to set up a test case. I likely missed some bundle parsing cases for multi-entry since I avoid using multi-entry whenever possible for performance reasons.
Oh that's very interesting. I can intuitively understand why would it be a performance drain, do you have any links where I can learn more (multi entry webpack)? 🙏 I'll do some digging of my own in the meanwhile :)
@keepitterron it's a little buried in the docs, but there now: https://webpack.js.org/plugins/module-concatenation-plugin/#optimization-bailouts
We bundle multiple separate 'apps' so we definitely need multiple entries, not something we can avoid unfortunately.
For those hitting this issue, you can disable automatic modernization via new OptimizePlugin({ modernize: false }). This improves performance, but will use the unmodified ES5 source of most npm modules since they do not publish modern code.