Skip to content

Commit

Permalink
fix: fix cache invalidation for non-optimized deps with cross imports
Browse files Browse the repository at this point in the history
fix #1401
  • Loading branch information
yyx990803 committed Jan 7, 2021
1 parent ca95d97 commit 11c407a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/index.ts
Expand Up @@ -412,5 +412,5 @@ export function getDepHash(
if (configFile) {
content += fs.readFileSync(configFile, 'utf-8')
}
return createHash('sha1').update(content).digest('base64')
return createHash('sha256').update(content).digest('hex').substr(0, 8)
}
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -282,7 +282,10 @@ export function tryNodeResolve(
// files actually inside node_modules so that locally linked packages
// in monorepos are not cached this way.
if (resolved.includes('node_modules')) {
resolved = injectQuery(resolved, `v=${pkg.data.version}`)
const versionHash = server?.optimizeDepsMetadata?.hash
if (versionHash) {
resolved = injectQuery(resolved, `v=${versionHash}`)
}
}
return { id: resolved }
}
Expand Down

0 comments on commit 11c407a

Please sign in to comment.