From 011e4a70ba4ee9740b89970c65a51dc4a3921ef1 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:46:59 +0900 Subject: [PATCH] fix(optimizer): trigger onCrawlEnd after manual included deps are registered --- packages/vite/src/node/optimizer/optimizer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/optimizer/optimizer.ts b/packages/vite/src/node/optimizer/optimizer.ts index a0a526b4a61685..8349e914dfe6c9 100644 --- a/packages/vite/src/node/optimizer/optimizer.ts +++ b/packages/vite/src/node/optimizer/optimizer.ts @@ -162,7 +162,6 @@ export function createDepsOptimizer( cachedMetadata || initDepsOptimizerMetadata(environment, sessionTimestamp) if (!cachedMetadata) { - environment.waitForRequestsIdle().then(onCrawlEnd) waitingForCrawlEnd = true // Enter processing state until crawl of static imports ends @@ -187,6 +186,8 @@ export function createDepsOptimizer( newDepsDiscovered = true } + environment.waitForRequestsIdle().then(onCrawlEnd) + if (noDiscovery) { // We don't need to scan for dependencies or wait for the static crawl to end // Run the first optimization run immediately