Skip to content

Commit

Permalink
fix: deps optimizer idle logic for workers (fix #8479)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jun 8, 2022
1 parent fba82d0 commit 449a54b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/vite/src/node/optimizer/optimizer.ts
Expand Up @@ -521,8 +521,12 @@ export async function initDepsOptimizer(

function registerWorkersSource(id: string): void {
workersSources.add(id)
// Avoid waiting for this id, as it may be blocked by the rollup
// bundling process of the worker that also depends on the optimizer
registeredIds = registeredIds.filter((registered) => registered.id !== id)
if (waitingOn === id) {
waitingOn = undefined
runOptimizerWhenIdle()
}
}

Expand All @@ -545,10 +549,12 @@ export async function initDepsOptimizer(
waitingOn = next.id
const afterLoad = () => {
waitingOn = undefined
if (registeredIds.length > 0) {
runOptimizerWhenIdle()
} else if (!workersSources.has(next.id)) {
getDepsOptimizer(config)?.run()
if (!workersSources.has(next.id)) {
if (registeredIds.length > 0) {
runOptimizerWhenIdle()
} else {
getDepsOptimizer(config)?.run()
}
}
}
next
Expand Down

0 comments on commit 449a54b

Please sign in to comment.