From d804699ad0c7dad37127bf9b7677356392c2bee2 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 2 Dec 2026 19:05:38 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Keep=20Svelte's=20browser=20runt?= =?UTF-8?q?ime=20in=20the=20production=20bundle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test setup for reactive reads set resolve.conditions for every mode. Outside tests the empty list replaced Vite's defaults, so Svelte resolved to its server build, where onMount is a no-op that the bundler drops. The layout then never resolved its sign-in gate and showed "Loading…" forever. The conditions are now only set for vitest. --- web/vite.config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index 0002ade..f762733 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -9,8 +9,10 @@ import { VitePWA } from 'vite-plugin-pwa'; const buildId = Date.now().toString(); export default defineConfig(({ mode }) => ({ - // Vitest resolves the `browser` export of Svelte, so effects re-run in tests like in the app. - resolve: { conditions: mode === 'test' ? ['browser'] : [] }, + // Vitest needs the `browser` export of Svelte so that effects re-run in tests like in the app. + // Builds must not set `resolve.conditions`: an explicit list replaces Vite's defaults and + // resolves Svelte to its server build, where onMount is a no-op that gets tree-shaken away. + ...(mode === 'test' ? { resolve: { conditions: ['browser'] } } : {}), plugins: [ sveltekit(), VitePWA({