Skip to content

Commit

Permalink
fix(optimizer): define crawlDeps after scanProcessing and optimizatio…
Browse files Browse the repository at this point in the history
…nResult are complete (fix vitejs#14284) (vitejs#14285)
  • Loading branch information
anyesu authored and Gaubee committed Sep 13, 2023
1 parent 4459af0 commit 32f8dd3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/optimizer/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,6 @@ async function createDepsOptimizer(
return
}

const crawlDeps = Object.keys(metadata.discovered)

// Await for the scan+optimize step running in the background
// It normally should be over by the time crawling of user code ended
await depsOptimizer.scanProcessing
Expand All @@ -630,6 +628,7 @@ async function createDepsOptimizer(
optimizationResult = undefined
currentlyProcessing = false

const crawlDeps = Object.keys(metadata.discovered)
const scanDeps = Object.keys(result.metadata.optimized)

if (scanDeps.length === 0 && crawlDeps.length === 0) {
Expand Down Expand Up @@ -680,6 +679,7 @@ async function createDepsOptimizer(
runOptimizer(result)
}
} else {
const crawlDeps = Object.keys(metadata.discovered)
currentlyProcessing = false

if (crawlDeps.length === 0) {
Expand Down

0 comments on commit 32f8dd3

Please sign in to comment.