cloudflare-mbt-worker-bundle

Installation
SKILL.md

Cloudflare Workers + MoonBit bundle pipeline

Use cf, cloudflare.config.ts and the Cloudflare Vite plugin to bundle MoonBit's JS output with the TypeScript Worker entry. See mizchi/cf-example (~/ghq/github.com/mizchi/cf-example) for the current cf/Vite setup; its checked versions are cf beta.5 and the Vite plugin beta on Node.js 24.

Pipeline

moon build --target js --release
  → prepare-worker (FFI rewrites into src/_generated/<PKG>-core.js)
  → cf build --mode <mode>
  → check emitted bundle
  → cf deploy --prebuilt --mode <same-mode> --dry-run
  → cf deploy --prebuilt --mode <same-mode>

Preparation must run before every build that will ship MoonBit changes. For local development, prepare the generated JS first, run pnpm exec cf dev, and regenerate it when MoonBit sources change; Vite does not invoke moon build automatically.

MoonBit emits plain ESM JS. The TypeScript entry side-effect imports the prepared file, which registers globalThis.__appServerFetch. Importing the original _build/ file bypasses the rewrites and can produce a Worker that hangs.

Installs
44
Repository
mizchi/skills
GitHub Stars
416
First Seen
May 26, 2026