Skip to content

docs(cloudflare): workerd-prelude is for esbuild-bundled entries only - #393

Merged
Madraka merged 1 commit into
mainfrom
docs/prelude-esbuild-only
Dec 2, 2026
Merged

Madraka merged 1 commit into
mainfrom
docs/prelude-esbuild-only

Conversation

@Madraka

@Madraka Madraka commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

What

Docs only: @cloudhal/cloudflare/workerd-prelude is for entries that wrangler bundles with esbuild, such as the admin entry that cloudhal deploy writes. An entry that Vite/Rollup bundles must not import it. That covers the Astro site Worker and a playground.

  • packages/cloudflare/src/workerd-prelude.ts: the module comment says so.
  • packages/cloudflare/README.md: the playground example no longer imports the prelude, and a paragraph explains why.
  • docs/adr/0012-cloudflare-deployment.md: the negative consequence notes the Vite case.
  • A patch changeset for @cloudhal/cloudflare.

No code changes. The generated admin entry and the workerd test fixtures, all wrangler-bundled, keep the import.

Why

With Astro 7.4.13, the prelude's top-level await import("zod/v4") lands in the entry chunk, and the zod facade chunk imports the entry chunk back. The Worker then fails at startup with "Top-level await in module is unsettled". Rollup already orders zod correctly, so Vite builds do not need the workaround. try's fix is cloudhal-dev/try#14.

Closes #392 once cloudhal-dev/try#14 is deployed.

🤖 Generated with Claude Code

An entry bundled by Vite/Rollup (an Astro build, a playground) must not
import it: Rollup orders zod correctly, and with Astro 7.4.13 the
prelude's top-level await can form a chunk cycle that stops the Worker at
startup. Module comment, README example and ADR-0012 say so.

Refs #392

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
@Madraka
Madraka merged commit 884527e into main Dec 2, 2026
9 checks passed
@Madraka
Madraka deleted the docs/prelude-esbuild-only branch December 2, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workers built by Astro 7.4.13 fail at startup: workerd-prelude's top-level await forms a chunk cycle with zod

1 participant