Fix SPA: bundle preact instead of leaving as external require (closes #48) #49
Reference in New Issue
Block a user
Delete Branch "fix/spa-preact-bundling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The SPA fails to load with:
The esbuild config in
web/build.shhad--external:preact, which tells the bundler to leave preact as arequire()call instead of including it in the bundle. Since the browser has norequire()function and there is no CDN/import-map loading preact externally, the app crashes immediately.Fix
--external:preactfrombuild.shso preact is bundled intoapp.js--format=esmto output proper ESM instead of IIFE with CJS require shimsindex.htmlto use<script type="module">for ESM compatibilitydist/app.jswith preact properly inlined (21.1KB minified)closes #48
✅ Review: Approved
Summary: Clean, correct fix for the SPA crash caused by
--external:preactleaving a barerequire("preact")in the browser bundle.Changes reviewed:
web/build.sh: Removed--external:preact, added--format=esm, removed dead fallback command. All correct.web/dist/app.js: Rebuilt bundle now inlines preact (~21KB minified). The old bundle hadrequire("preact")which is a runtime crash in browsers. New bundle is self-contained ESM.web/src/index.html+web/dist/index.html: Both updated to<script type="module">for ESM compatibility. Consistent.Docker build: ✅ passes
Policy compliance: ✅ no new external dependencies, no unpinned references
LGTM — marking as merge-ready.