Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: overwrite deps info browserHash only on commit #7359

Merged
merged 1 commit into from Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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