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: ensure deps optimizer first run, fixes #8750 #8775

Merged
merged 3 commits into from Jun 26, 2022
Merged
Changes from 2 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
12 changes: 11 additions & 1 deletion packages/vite/src/node/optimizer/optimizer.ts
Expand Up @@ -527,6 +527,16 @@ 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
if (isBuild) {
setTimeout(() => {
if (!firstRunCalled && registeredIds.length === 0) {
getDepsOptimizer(config)?.run()
}
}, runOptimizerIfIdleAfterMs)
}
}

function registerWorkersSource(id: string): void {
Expand Down Expand Up @@ -559,7 +569,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