Summary
On a Cloudflare Workers (D1 + R2) Astro SSR site that registers native plugins via definePlugin, upgrading emdash from 0.15.0 → 0.17.1 or 0.17.2 makes every route return HTTP 500 at runtime. astro check and astro build pass cleanly — the failure only appears at runtime under workerd:
ReferenceError: Cannot access 'SIMPLE_ID' before initialization
at defineNativePlugin (dist/server/chunks/adapt-sandbox-entry_*.mjs:796:3)
at definePlugin (dist/server/chunks/adapt-sandbox-entry_*.mjs:791:10)
at createPlugin (dist/server/chunks/wait-until_*.mjs:758:10)
at <module init> (dist/server/chunks/wait-until_*.mjs:1014:3)
at <module init> (dist/server/chunks/adapt-sandbox-entry_*.mjs:770:5)
SIMPLE_ID is a const declared later in the same emitted chunk than a top-level createPlugin → definePlugin → defineNativePlugin call that reads it — i.e. a temporal-dead-zone / circular-init ordering problem in the bundled output.
Environment
- emdash 0.17.2 (also reproduced on 0.17.1; 0.15.0 is unaffected)
- @emdash-cms/cloudflare 0.17.2, @emdash-cms/admin 0.17.2
- astro 6.4.4, @astrojs/cloudflare 13.6.1
- wrangler 4.98.0 / workerd, Node 24, pnpm 11
output: 'server', emdash({ database: d1({binding:'DB'}), storage: r2({binding:'MEDIA'}) })
- 3 native plugins registered via
definePlugin (entrypoint module paths)
Reproduction
pnpm build
npx wrangler dev --config dist/server/wrangler.json
curl http://127.0.0.1:8799/ → 500, log shows the trace above (every route).
The adapter build emits no_bundle: true, so a real wrangler deploy behaves identically.
Notes / what was tried
- Reproduces with the docs-minimal Cloudflare config too (no custom
vite.optimizeDeps / ssr.noExternal). The integration itself sets ssr.noExternal: ["emdash", "@emdash-cms/admin"], so emdash is re-bundled into the worker regardless — which appears to be where Rollup flattens the circular init into a TDZ.
- 0.17.1 and 0.17.2 both affected; 0.15.0 works fine on the identical setup.
Is this a known issue, and is there a recommended config or a fix version? Happy to provide a minimal reproduction repo if useful.
Summary
On a Cloudflare Workers (D1 + R2) Astro SSR site that registers native plugins via
definePlugin, upgradingemdashfrom 0.15.0 → 0.17.1 or 0.17.2 makes every route return HTTP 500 at runtime.astro checkandastro buildpass cleanly — the failure only appears at runtime underworkerd:SIMPLE_IDis aconstdeclared later in the same emitted chunk than a top-levelcreatePlugin→definePlugin→defineNativePlugincall that reads it — i.e. a temporal-dead-zone / circular-init ordering problem in the bundled output.Environment
output: 'server',emdash({ database: d1({binding:'DB'}), storage: r2({binding:'MEDIA'}) })definePlugin(entrypoint module paths)Reproduction
pnpm buildnpx wrangler dev --config dist/server/wrangler.jsoncurl http://127.0.0.1:8799/→ 500, log shows the trace above (every route).The adapter build emits
no_bundle: true, so a realwrangler deploybehaves identically.Notes / what was tried
vite.optimizeDeps/ssr.noExternal). The integration itself setsssr.noExternal: ["emdash", "@emdash-cms/admin"], so emdash is re-bundled into the worker regardless — which appears to be where Rollup flattens the circular init into a TDZ.Is this a known issue, and is there a recommended config or a fix version? Happy to provide a minimal reproduction repo if useful.