Repository navigation
docs(cloudflare): workerd-prelude is for esbuild-bundled entries only - #393
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Docs only:
@cloudhal/cloudflare/workerd-preludeis for entries that wrangler bundles with esbuild, such as the admin entry thatcloudhal deploywrites. 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.@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