Skip to content

Commit

Permalink
fix: overwrite deps info browserHash only on commit (#7359)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 17, 2022
1 parent fde0f3c commit 1e9615d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -519,12 +519,6 @@ export async function createOptimizeDepsRun(
}

if (alteredFiles) {
// Overrite individual hashes with the new global browserHash, a full page reload is required
// New deps that ended up with a different hash replaced while doing analysis import are going to
// return a not found so the browser doesn't cache them. And will properly get loaded after the reload
for (const id in deps) {
metadata.optimized[id].browserHash = newBrowserHash
}
metadata.browserHash = newBrowserHash
}

Expand All @@ -533,6 +527,14 @@ export async function createOptimizeDepsRun(
return {
alteredFiles,
commit() {
if (alteredFiles) {
// Overwrite individual hashes with the new global browserHash, a full page reload is required
// New deps that ended up with a different hash replaced while doing analysis import are going to
// return a not found so the browser doesn't cache them. And will properly get loaded after the reload
for (const id in deps) {
metadata.optimized[id].browserHash = newBrowserHash
}
}
// Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync
commitProcessingDepsCacheSync()
processing.resolve()
Expand Down

0 comments on commit 1e9615d

Please sign in to comment.