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)
This commit is contained in:
2026-03-13 22:24:49 -04:00
parent 557ac77458
commit f73ca5fdab
+3
View File
@@ -7,6 +7,9 @@ export default defineConfig({
input: "web/src/main.ts",
output: {
entryFileNames: "main.js",
manualChunks: () => {
return "everything";
},
},
},
target: "es2020",