Skip to content

Commit

Permalink
fix: ensure deps optimizer first run
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jun 24, 2022
1 parent d4dcdd1 commit 09e7beb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/vite/src/node/optimizer/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@ export async function initDepsOptimizer(
seenIds = new Set<string>()
workersSources = new Set<string>()
waitingOn = undefined
// If all the inputs are dependencies, we aren't going to get any
// delayDepsOptimizerUntil(id) calls. We need to guard against this
// by forcing a rerun if no deps have been registered
setTimeout(() => {
if (!firstRunCalled && registeredIds.length === 0) {
getDepsOptimizer(config)?.run()
}
}, runOptimizerIfIdleAfterMs)
}

function registerWorkersSource(id: string): void {
Expand Down Expand Up @@ -559,7 +567,7 @@ export async function initDepsOptimizer(
waitingOn = next.id
const afterLoad = () => {
waitingOn = undefined
if (!workersSources.has(next.id)) {
if (!firstRunCalled && !workersSources.has(next.id)) {
if (registeredIds.length > 0) {
runOptimizerWhenIdle()
} else {
Expand Down

0 comments on commit 09e7beb

Please sign in to comment.