From 52a6732482398db97517e62e1ba05fe350da6108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Wed, 7 Dec 2022 21:57:39 +0900 Subject: [PATCH] fix: await scanner (#11242) --- packages/vite/src/node/optimizer/optimizer.ts | 10 +++++++++- .../__tests__/multiple-entrypoints.spec.ts | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/optimizer/optimizer.ts b/packages/vite/src/node/optimizer/optimizer.ts index 7653e9ae87a3fa..a791f8a1dd45b5 100644 --- a/packages/vite/src/node/optimizer/optimizer.ts +++ b/packages/vite/src/node/optimizer/optimizer.ts @@ -161,10 +161,16 @@ async function createDepsOptimizer( let firstRunCalled = !!cachedMetadata let postScanOptimizationResult: Promise | undefined + let discoverProjectDependenciesPromise: + | Promise> + | undefined let optimizingNewDeps: Promise | undefined async function close() { closed = true + await discoverProjectDependenciesPromise?.catch(() => { + /* ignore error for scanner because it's not important */ + }) await postScanOptimizationResult await optimizingNewDeps } @@ -202,7 +208,9 @@ async function createDepsOptimizer( try { debug(colors.green(`scanning for dependencies...`)) - const deps = await discoverProjectDependencies(config) + discoverProjectDependenciesPromise = + discoverProjectDependencies(config) + const deps = await discoverProjectDependenciesPromise debug( colors.green( diff --git a/playground/multiple-entrypoints/__tests__/multiple-entrypoints.spec.ts b/playground/multiple-entrypoints/__tests__/multiple-entrypoints.spec.ts index 71b93a4fa97281..8215fb8f301fab 100644 --- a/playground/multiple-entrypoints/__tests__/multiple-entrypoints.spec.ts +++ b/playground/multiple-entrypoints/__tests__/multiple-entrypoints.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from 'vitest' import { getColor, page, untilUpdated } from '~utils' -test.skip('should have css applied on second dynamic import', async () => { +test('should have css applied on second dynamic import', async () => { await untilUpdated(() => page.textContent('.content'), 'Initial', true) await page.click('.b')