updating to version 1.8.10 causes new error in CommonsChunkPlugin
See original GitHub issueVersion 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
Issue Analytics
- State:
- Created 8 years ago
- Comments:26 (8 by maintainers)
Top Results From Across the Web
MEAN NPM Cannot find module 'webpack/lib/optimize ...
I have already checked the following threads and found that the cause of the error is a deprecated class. Webpack migration 3 ->...
Read more >CommonsChunkPlugin - webpack
The CommonsChunkPlugin is an opt-in feature that creates a separate file (known as a chunk), consisting of common modules shared between multiple entry ......
Read more >angular/angular-cli - Gitter
Hi. I am trying to upgrade my Angular from 9 to 13 but I am using SSR and Web-Workers. Everything was fine until...
Read more >webpack: Unraveling CommonsChunkPlugin | by John Tucker
Shortly after I finished this series, webpack released a new major (3.x.x) version. As such, I updated the last example in this article...
Read more >ASP.NET Core, Angular with Webpack and Visual Studio
Update to the latest versions: npm install npm@latest -g. npm install yarn -g. See this link for more details on yarn:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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…)