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

Problems with the splitVendorChunkPlugin #16268

Closed
7 tasks done
alSergey opened this issue Mar 25, 2024 · 1 comment
Closed
7 tasks done

Problems with the splitVendorChunkPlugin #16268

alSergey opened this issue Mar 25, 2024 · 1 comment

Comments

@alSergey
Copy link

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

  1. Run npx nuxt analyze

After this, default chunks will be generated. The default chunk contains dependencies that are used only there.

Снимок экрана 2024-03-25 в 16 03 19
  1. 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.

Снимок экрана 2024-03-25 в 16 04 06

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.4

Used Package Manager

npm

Logs

No response

Validations

@patak-dev
Copy link
Member

The splitVendorChunkPlugin was kept to allow projects have an easy path to be backward compatible. It is hard to implement a general solution for every project at the level Vite works. I think the best is that Nuxt offers users what works best for them.

I think we should remove the mention to it from the docs and deprecate it to be able to completely remove it in Vite 6.

@patak-dev patak-dev closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants