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
This commit is contained in:
2026-03-07 05:48:10 -08:00
parent 2da7f11484
commit 2a29f41aa8
4 changed files with 6 additions and 14 deletions

4
web/dist/app.js vendored

File diff suppressed because one or more lines are too long

2
web/dist/index.html vendored
View File

@@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script src="/app.js"></script>
<script type="module" src="/app.js"></script>
</body>
</html>