From 17b904a8a4be21f3b63b7e2c8f9950c11e199272 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 13:43:37 +0000 Subject: [PATCH] Paraglide: locale modules in the dev server, as with Paraglide 2 Paraglide 2's Vite plugin generated one module per locale outside of production builds and one per message only for `vite build`. Setting `outputStructure: "message-modules"` unconditionally made the dev server load every message as its own module: 1577 Paraglide requests instead of 5 on the first page, about twice the load time, and the E2E tests against the dev server took 2.5 instead of 1.2 minutes and timed out. `process.env.NODE_ENV === "production"` is the condition Paraglide 2 used; Vite sets it before it loads the config (`production` for vite build, `development` for the dev server, `test` under Vitest). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Y3rdfanxjpLranVFzXfytu --- web/vite.config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/vite.config.ts b/web/vite.config.ts index 624d06c..f98adaa 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -11,7 +11,10 @@ export default defineConfig({ paraglideVitePlugin({ project: "./project.inlang", outdir: "./src/paraglide", - outputStructure: "message-modules", + // Paraglide 2's default: one module per locale in the dev server and tests (a few requests), + // one per message in production builds (tree shaking). v3 would serve virtual modules only Vite + // can resolve. + outputStructure: process.env.NODE_ENV === "production" ? "message-modules" : "locale-modules", strategy: ["localStorage", "preferredLanguage", "baseLocale"], }), tanstackRouter({ target: "react", autoCodeSplitting: true }),