From dc6041099ccd5767764fb8c99a169869bbd13f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 22 Nov 2024 20:10:20 +0900 Subject: [PATCH] fix(optimizer): trigger onCrawlEnd after manual included deps are registered (#18733) --- 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