Skip to content
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

splitChunks.cacheGroups.defaultVendors not extending default behavior #5174

Open
SevenOutman opened this issue Jul 8, 2021 · 6 comments
Open

Comments

@SevenOutman
Copy link
Contributor

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:

@webpack-bot
Copy link

For maintainers only:

  • webpack-4
  • webpack-5
  • bug
  • critical-bug
  • enhancement
  • documentation
  • performance
  • dependencies
  • question

@alexander-akait
Copy link
Member

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

@alexander-akait alexander-akait transferred this issue from webpack/webpack Jul 12, 2021
@SevenOutman
Copy link
Contributor Author

Yes, using splitChunks.cacheGroups.defaultVendors is 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.

@alexander-akait
Copy link
Member

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 webpack/webpack#13726 for objects

@SevenOutman
Copy link
Contributor Author

Thanks for your explanation! Keeping an eye on the PR now.

@alexander-akait
Copy link
Member

Let's keep open here, we need improve our docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants