From f73ca5fdab38f17affb97251815c226835546b35 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 13 Mar 2026 22:24:49 -0400 Subject: [PATCH] fix(vite): prevent Alpine.js code splitting to eliminate variable redeclaration error Configure Vite to bundle all code into a single chunk using manualChunks, preventing Alpine.js from being split into multiple modules that caused "redeclaration of let Xo" errors during initialization. This resolves the critical bug where Alpine.js would load twice on pages using @Header, breaking all @click handlers and causing form buttons to fall back to default browser behavior (unwanted navigation/form submission). Technical details: - The default Vite code-splitting was creating multiple ESM chunks - Alpine's reactive system uses let Xo internally - Multiple chunks caused Xo to be declared multiple times - manualChunks() forces everything into a single bundle Fixes #XXX (Alpine.js redeclaration error) --- vite.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vite.config.ts b/vite.config.ts index 07324f1..9fb4d8b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,6 +7,9 @@ export default defineConfig({ input: "web/src/main.ts", output: { entryFileNames: "main.js", + manualChunks: () => { + return "everything"; + }, }, }, target: "es2020",