-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Case against enabling AutomaticCommonsChunksPlugin
in webpack by default
#4977
Comments
According to documentation create-react-app/packages/react-scripts/config/webpack.config.prod.js Lines 161 to 164 in 52449c3
|
Im not currently in any CRA releated project where I can test this and toy with chunking. But if I remember correctly you can configure webpack to work like this: Vendors for chunk A, B & C => vendors-all.js Feel free to open a PR! |
@andriijas Thanks for the response! The problem is that we can't configure webpack in CRA unless we eject. That's an option but not an attractive one unless it's really necessary. |
Easiest way for you is to fiddle with cra in node_modules of your app and see if you can find any bug in the configuration, then copy solution to cloned cra src and submit PR with propsal for discussion. when done just remove your local node_modules and yarn/npm to reset. |
Always producing a single vendor file should not be a default. |
@andriijas It's not a bug, in this case. It's the expected behavior. The issue is that this behavior can be suboptimal in many scenarios, for example if the vendor bundle ends up being too large. It defeats the purpose of code splitting, which is why I am asking for more fine-grained control of this setting. The only fiddle with CRA we would do is switching off |
For reference: parcel-bundler/parcel#885 |
I'm not arguing against it - I had a hard time trying to figure out sane defaults when I made the webpack 4 pr. Just open a pr and argue for the case. |
Is this a bug report?
No. This is a discussion of the changes recently introduced by the
AutomaticCommonsChunksPlugin
webpack plugin, that is now enabled by default in CRA v2. The issue is that the vendor chunk produced for our application is approaching 100KB in size, which seems to defeat the purpose of using dynamic imports for code splitting.Here are the chunks we get in CRA v2.0.0-next.66cc7a90 without the new plugin enabled:
Here are the chunks we get in CRA v2.0.0-next.a671462c:
Our concern is that the size of the vendor chunk will continue to grow as we add more third party components to our application, and with this plugin enabled by default, we will be unable to customize the code splitting effectively.
Proposed solutions
AutomaticCommonsChunksPlugin
or make it opt-inRelated PRs/issues
The text was updated successfully, but these errors were encountered: