From 20c510c47251561df314ad2de83d80d757cd3688 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Mon, 20 Mar 2023 21:36:09 +0100 Subject: [PATCH] fix: import @vite/client in browser code for handling optimizer --- packages/browser/src/client/main.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/browser/src/client/main.ts b/packages/browser/src/client/main.ts index c89721f3075d..ebf2ad4e67b0 100644 --- a/packages/browser/src/client/main.ts +++ b/packages/browser/src/client/main.ts @@ -71,6 +71,10 @@ ws.addEventListener('open', async () => { let hasSnapshot = false async function runTests(paths: string[], config: any, client: VitestClient) { + // need to import it before any other import, otherwise Vite optimizer will hang + const viteClientPath = '/@vite/client' + await import(viteClientPath) + // we use dynamic import here, because this file is bundled with UI, // but we need to resolve correct path at runtime const path = '/__vitest_index__'