-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Pre-Bundled dependencies used over locally linked dependency when built before linking #6718
Copy link
Copy link
Closed
Labels
feat: deps optimizerEsbuild Dependencies OptimizationEsbuild Dependencies Optimization
Description
Describe the bug
Reproduction instructions
- Download https://stackblitz.com/edit/vitejs-vite-9ibgrz (just a base Vite project with a
my-test-projectdirectory that has a boilerplatepackage.jsonto use)- StackBlitz uses
turbounder the hood for installing packages and I can't figure out how to do the local linking which is essential the reproduction.yarn link->ERR!: Unknown command 'link'
- StackBlitz uses
yarn- Fake a
yarn add my-test-dependencyby runningcp -R my-test-dependency node_modules/my-test-dependency yarn dev(this will create pre-bundled dependencies formy-test-dependencyand populatenode_modules/.vite)- Notice
my-test-dependency asdflog in the devtools console - Get
my-test-dependencyready for linking:cd my-test-dependency && yarn link && cd .. - Locally link it in your project:
yarn link my-test-dependency yarn dev- Notice
my-test-dependency asdflog in the devtools console - Edit
./my-test-dependency/index.jsto a differentconsole.log('other message')just to show that Vite is pulling from the wrong spot - Notice how the log message never changes to what you set
This use-case happens when you're doing some development on a project, find a problem in a sub-dependency, then link it locally to dive deeper.
Expected result
Vite would see that the dependency/package is now linked locally and will bust it's own pre-bundle cache.
Workaround
- Clear your pre-bundled dependency build cache
rm -rf ./node_modules/.vite - Notice how Vite is correctly bundling your locally linked package now and has the updated message
Dev notes
Relevant docs:
- https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies
- https://vitejs.dev/guide/dep-pre-bundling.html
Reproduction
StackBlitz uses turbo under the hood for installing packages and I can't figure out how to do the local linking which is essential the reproduction. yarn link -> ERR!: Unknown command 'link'. See the reproduction steps above instead ^
System Info
vite@2.7.13
npx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
npx: installed 1 in 2.131s
System:
OS: Windows 10 10.0.19044
Binaries:
Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - C:\Program Files\nodejs\yarn.CMD
npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 97.0.4692.99Used Package Manager
yarn
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
Metadata
Metadata
Assignees
Labels
feat: deps optimizerEsbuild Dependencies OptimizationEsbuild Dependencies Optimization
