webpack: updating to version 1.8.10 causes new error in CommonsChunkPlugin
Version 1.8.9 succeeds but when updating to 1.8.10 I get an error:
ERROR in CommonsChunkPlugin: While running in normal mode it's not allowed to use a non-entry chunk
The bundle js is not output.
My build output from deploying to Heroku (this error is on line 514): https://gist.github.com/bdefore/838bbe5be65dcb114014
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 26 (8 by maintainers)
As I’ve learned the hard way, order matters when defining your vendor chunks in the CommonsChunkPlugin. for example…
This configuration works. Notice how in the
new webpack.optimize.CommonsChunkPlugin
invocation the vendor chunks are in reverse order. If i swap them I get errors in my resulting index.html Seems like a bug in the CommonsChunkPlugin internals. Thoughts?So through a lot of trial and error, I’ve ended up with a rather monolithic config for multiple common chunks with cache busting (truncated where possible…):
Which enables loading of the manifest (via inline script) followed by
entry
,polyfills
,react
, &vendor
… before finally loading one of the desiredpage
entry points. Each of these 4 chunks will only change their hash when their contents change. (e.g. onlyvendor
andpage
will get a new hash if a new vendor module is added topage
, andreact
only changes if the library does.) Each one depends on the others higher-up the chain, so as mentioned earlier, some of them could be rolled together for less complexity (entry
&polyfills
).Some observations after going through all this:
CommonsChunkPlugin
plugin. It wasn’t just the order, they also had to be chained together to move the bootstrap down the chain to the last one…entry
chunk.chunks
option works, and thechildren
option is still a mystery to me. Thechunks
documentation mentions “The chunk must be a child of the commons chunk”, andchildren
says “If true all children of the commons chunk are selected”, but what exactly is a parent/child relationship in this plugin? And how do these options relate to “While running in normal mode it’s not allowed to use a non-entry chunk”? “Normal mode” (or “mode” in general) is not mentioned outside of the error message.minChunks
andmodule
mutation just to be able to create multiple common chunks. It’s easy to make examples of multiple static common chunks(vianames
), or one dynamic common chunk (via aminChunks
function), but it feels very hard trying to combine those two configs together in a way that makes sense.babel-polyfill
modifies globals, so has a special need to be loaded early before other libraries, but there isn’t much documentation on how to load special cases like this for non-trivial entry points.(Sorry for the barrage of words…)