Fix SPA: bundle preact instead of leaving as external require (closes #48) #49

Merged
sneak merged 1 commits from fix/spa-preact-bundling into main 2026-03-07 14:53:14 +01:00

1 Commits

Author SHA1 Message Date
2a29f41aa8 fix: bundle preact into SPA instead of leaving as external require
All checks were successful
check / check (push) Successful in 57s
The esbuild config had --external:preact which told the bundler to leave
preact as a require() call instead of including it in the bundle. Since
the SPA loads app.js directly in the browser (no CDN or import map for
preact), the browser has no require() function and throws:

  Uncaught Error: Dynamic require of "preact" is not supported

Fix:
- Remove --external:preact from build.sh so preact is bundled into app.js
- Add --format=esm to output proper ESM instead of IIFE with CJS shims
- Update index.html to use <script type="module"> for ESM compatibility
- Remove the fallback build command (no longer needed)
- Rebuild dist/app.js with preact properly inlined

closes #48
2026-03-07 05:48:10 -08:00