🐛 Keep Svelte's browser runtime in the production bundle

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.
This commit is contained in:
2026-12-02 19:05:47 +01:00
parent d45c3d024f
commit d804699ad0
+4 -2
View File
@@ -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({