Uncaught Error: Dynamic require of "preact" is not supported
The esbuild config in web/build.sh had --external:preact, which tells the bundler to leave preact as a require() call instead of including it in the bundle. Since the browser has no require() function and there is no CDN/import-map loading preact externally, the app crashes immediately.
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 require shims
Update index.html to use <script type="module"> for ESM compatibility
Remove the dead fallback build command (was never reached since the first command succeeded)
Rebuild dist/app.js with preact properly inlined (21.1KB minified)
## Problem
The SPA fails to load with:
```
Uncaught Error: Dynamic require of "preact" is not supported
```
The esbuild config in `web/build.sh` had `--external:preact`, which tells the bundler to leave preact as a `require()` call instead of including it in the bundle. Since the browser has no `require()` function and there is no CDN/import-map loading preact externally, the app crashes immediately.
## 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 require shims
- Update `index.html` to use `<script type="module">` for ESM compatibility
- Remove the dead fallback build command (was never reached since the first command succeeded)
- Rebuild `dist/app.js` with preact properly inlined (21.1KB minified)
closes #48
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
Summary: Clean, correct fix for the SPA crash caused by --external:preact leaving a bare require("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 had require("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.
✅ **Review: Approved**
**Summary:** Clean, correct fix for the SPA crash caused by `--external:preact` leaving a bare `require("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 had `require("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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.