`splitChunks.cacheGroups.defaultVendors` not extending default behavior
Bug report
I was trying to split my app code and all node_modules packages into two separate bundles and I wanted to name the dependencies bundle vendors.js.
Here's my configuration:
splitChunks: {
chunks: 'all',
cacheGroups: {
defaultVendors: {
name: 'vendors',
},
},
},
What is the current behavior?
The output app bundle contains only runtime scaffold and vendors bundle contains both dependencies and all my app code.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
The app bundle should contain my app code and the vendors bundle contains node_modules dependencies.
FYI, adding test: /[\\/]node_modules[\\/]/ rule to defaultVendors config solves this problem. So I believe providing defaultVendors option replaced the default behavior instead of extending it.
Other relevant information: webpack version: 5.43.0 Node.js version: 14.15.5 Operating System: macOS 11.4 Additional tools:
For maintainers only:
- [ ] webpack-4
- [ ] webpack-5
- [ ] bug
- [ ] critical-bug
- [ ] enhancement
- [ ] documentation
- [ ] performance
- [ ] dependencies
- [ ] question
Yes, using splitChunks.cacheGroups.defaultVendors is not extending default behavior, it is expected (https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L1030), we need docs it, feel free to feedback
Yes, using
splitChunks.cacheGroups.defaultVendorsis not extending default behavior, it is expected
I see. But why should it not be extending default behavior? It's not so straightforward from my point of view. You always need to search for the complete default config when you only need to overwrite one attribute in it.
Because it was implemented, if we extend other developers ask why we extend, and we decided do not extend, like it happens in JS, when you change property of object, in webpack we have ... syntax for merging/extending, but here blocker https://github.com/webpack/webpack/pull/13726/ for objects
Thanks for your explanation! Keeping an eye on the PR now.
Let's keep open here, we need improve our docs