-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Labels
p4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)
Description
- Read the docs.
- 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/vue-next instead.
- This is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
Describe the bug
Importing dependencies in node_modules by fs paths will cause unexpected behavior, because we only do version hash injection for bare imports:
vite/packages/vite/src/node/plugins/resolve.ts
Lines 371 to 374 in 26c46b9
| const versionHash = server._optimizeDepsMetadata?.browserHash | |
| if (versionHash && isJsType) { | |
| resolved = injectQuery(resolved, `v=${versionHash}`) | |
| } |
Reproduction
Reproduce repo: https://github.com/meteorlxy/repro-vite-2503
- Having a
foomodule:
// node_modules/foo/index.js
export default Symbol()- Having a
barmodule that depends onfoomodule:
// node_modules/bar/index.js
import fooSymbol from 'foo'
export default fooSymbol- Importing
fooandbarvia fs paths:
// index.js
import fooSymbol from './node_modules/foo'
import barSymbol from './node_modules/bar'
console.log(fooSymbol === barSymbol) // falseExplanation
- No version hash will be injected in
index.jsbecause there is no bare import. - Version hash will be injected in
node_modules/bar/index.js, because it uses bare import forfoomodule.
System Info
viteversion: 2.0.5- Operating System: Linux
- Node version: 12.16.1
- Package manager (npm/yarn/pnpm) and version: npm 7.6.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)