-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Description
Describe the bug
The issue is as follows, I have a vite application and a vite components library
The application consumes the components library
In the vite-library i have a peer dependency,
I've configured the library to not bundle that peer dependency.
The vite app is not importing code that is using the peer dependency.
When building the vite app, the bundle includes the peer dependency code.
I think the issue is in how the vite library is bundled, it imports dependencies marked as external and for some reason this causes vite to bundle them like they are globally needed
I've added a link for reproduction, steps to reproduce:
- npm install the npm workspace
- run npm build in the
vite-libfolder - run npm build in the
vite-appfolder -> the index.js size will be 184kb~ - change
ComponentCto not importreact-bootstrap(component C is not used at all in vite app) - run npm build in the
vite-libfolder - run npm build in the
vite-appfolder -> the index.js size will be 142kb~ -> 40 kb changed although the app code didn't change at all (and it does not importComponentC)
Reproduction
https://stackblitz.com/edit/vitejs-vite-hzzn14?file=vite-app/main.jsx
System Info
System:
OS: Linux 5.0 undefined
CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: Unknown - /bin/jsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.10 - /bin/yarn
npm: 7.17.0 - /bin/npm
npmPackages:
@vitejs/plugin-react: ^1.3.0 => 1.3.1
vite: ^2.9.5 => 2.9.6Used 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 https://github.com/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.
Reactions are currently unavailable