Uh oh!
There was an error while loading. Please reload this page.
fix(playground): replace esm.sh with jsDelivr +esm — fixes HTTP 500 on core.mjs - #35
Conversation
esm.sh generates a split-entry bundle for typecomposer@0.1.56 that imports a generated /es2022/core.mjs sub-path. That sub-path returns HTTP 500: esbuild: No matching export in "node_modules/typecomposer/core/index.js" for import "Component" Root cause: typecomposer's core/* sub-modules re-import from "../.." (the root index), creating a circular dependency that esbuild (used by esm.sh) cannot resolve when building the split core.mjs entry. Fix: switch the import map URL to jsDelivr's +esm endpoint, which uses Rollup to produce a single-file ESM bundle from the root index.js directly. The resulting bundle is a flat 117 KB file with all named exports present and no circular dependency issue. Before: https://esm.sh/typecomposer@${VERSION} → 200 stub → imports /es2022/core.mjs → 500 After: https://cdn.jsdelivr.net/npm/typecomposer@${VERSION}/+esm → 200 single-bundle ESM (Rollup, 117 KB, CORS: *) Only PlaygroundView.ts is changed (1 line + updated comments). Build: ✓ 3486 modules, esbuild.wasm in dist/assets/, 15.32s
Uh oh!
There was an error while loading. Please reload this page.
lucas-spin
commented
Jun 12, 2026
Runtime Smoke Test — PR #35 (post-merge audit)Tool: Playwright 1.60 + Chromium Headless Shell 148 (headless, no display) ✅ What the CDN fix got right
The core CDN fix is correct. jsDelivr resolves the HTTP 500 that plagued esm.sh. ❌ New runtime blocker exposed by the fixRoot cause (two-layer):
Was this introduced by PR #35? ❌ No. PR #35 is exactly 1 line: Why wasn't it visible before? With Effect: The iframe renders an error panel ("Initialization Error: SecurityError…") instead of the default ✅/❌ Full checklist
Recommended follow-up fixThis needs one of: Option A (playground-side, minimal): Wrap Option B (playground-side, immediate workaround): In Option C (playground-side, cleanest): Use The right long-term fix is Option A — typecomposer's global initializer should be resilient to restricted environments (workers, sandboxed iframes, SSR). This is a separate issue from PR #35. Verdict: PR #35 needs a companion fix. The CDN URL change itself is correct and should stay. The localStorage error is a pre-existing layered bug (typecomposer core + PR #34's sandbox choice) that the CDN fix has now surfaced. |
Bug report (João)
Root cause
esm.shauto-generates a split-entry bundle fortypecomposer@0.1.56:The generated
core.mjsreturns HTTP 500 with:Why?
typecomposer'score/index.jsre-exports from sub-packages (./element,./components, …), and each of those sub-packages re-importsComponentfrom"../.."(the root). This creates a circular dependency that esbuild — used internally by esm.sh — cannot resolve when building its splitcore.mjsentry.The package has no
"exports"map and uses"type": "module", so esm.sh tries to split on the bare subpath and fails.Fix
Switch the import-map URL from
esm.shto jsDelivr+esm:jsDelivr's
+esmendpoint uses Rollup to produce a single flat ES module fromindex.jsdirectly, bypassing the circular subpath entirely. The result is a 117 KB file with all named exports (Component,VBox,DivElement,ButtonElement, etc.) and CORS headers.esm.sh/typecomposer@0.1.56core.mjs→ 500cdn.jsdelivr.net/npm/typecomposer@0.1.56/+esmValidation
Files changed
src/views/playground/PlaygroundView.tsesm.sh→cdn.jsdelivr.net/…/+esm; updated JSDoc commentManual browser verification still needed
net::ERR_ABORTED 500in DevTools NetworkAppPagerenders (purple gradient + click button)cc @zico15@joaodibba