-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Description
Describe the bug
splitVendorChunkPlugin not working with entry file from node_modules
The nuxt library provides an entry file from node_modules. The Vite plugin can't work with this.
Expected behavior
Vite generates 2 chunks: entry and vendors.
Actual behavior
Vite generates 1 entry chunk, which contains all dependencies (node_modules).
splitVendorChunkPlugin adds dependencies that were not in the original entry file.
Since the plugin performs a recursive search for importers, some dependencies may be marked as statically imported from the entry file, although this is not the case. In the example, this can be seen in the default chunk. These dependencies are used only in the default chunk, but they end up in the vendors chunk.
Expected behavior
The vendors chunk contains only those dependencies that were present in the original entry chunk.
Actual behavior
The vendors chunk contains dependencies that were not in the original entry chunk.
Reproduction
https://github.com/alSergey/vite-split-chunks-repro
Steps to reproduce
- Run
npx nuxt analyze
After this, default chunks will be generated. The default chunk contains dependencies that are used only there.
- Run
npx nuxt analyze --enable-chunks
After this, chunks will be generated using the splitVendorChunkPlugin. Dependencies from the default chunk moved to the vendors chunk.
System Info
System:
OS: macOS 14.4
CPU: (10) arm64 Apple M2 Pro
Memory: 119.48 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
Browsers:
Chrome: 123.0.6312.59
Safari: 17.4Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.