| 1 | # `@alchemy.run/cloudflare-runtime/rolldown` |
| 2 | |
| 3 | Rolldown plugin for Cloudflare Workers. |
| 4 | |
| 5 | ## Install |
| 6 | |
| 7 | ```bash |
| 8 | bun add @alchemy.run/cloudflare-runtime rolldown |
| 9 | ``` |
| 10 | |
| 11 | ## Usage |
| 12 | |
| 13 | ```ts |
| 14 | import { rolldown } from "rolldown"; |
| 15 | import cloudflare from "@alchemy.run/cloudflare-runtime/rolldown"; |
| 16 | |
| 17 | const bundle = await rolldown({ |
| 18 | input: "./src/index.ts", |
| 19 | plugins: [ |
| 20 | cloudflare({ |
| 21 | // Node.js compatibility is default-on for this date. |
| 22 | compatibilityDate: "2026-08-31", |
| 23 | }), |
| 24 | ], |
| 25 | }); |
| 26 | |
| 27 | await bundle.write({ |
| 28 | file: "./dist/index.js", |
| 29 | format: "esm", |
| 30 | sourcemap: true, |
| 31 | }); |
| 32 | ``` |
| 33 | |
| 34 | ## What It Does |
| 35 | |
| 36 | - Applies Cloudflare-friendly Rolldown defaults for resolution and output targeting. |
| 37 | - Treats supported `cloudflare:*` imports as external. |
| 38 | - Enables Node.js compatibility shims when `nodejs_compat` is set or the |
| 39 | compatibility date is `2026-08-04` or later. |
| 40 | - Supports Cloudflare-style additional modules for `.wasm`, `.bin`, `.txt`, `.html`, and `.sql`. |
| 41 | - Supports `.wasm?init` imports. |
| 42 | |
| 43 | ## Options |
| 44 | |
| 45 | - `compatibilityDate?: string` |
| 46 | - `compatibilityFlags?: string[]` |
| 47 | |
| 48 | ## License |
| 49 | |
| 50 | MIT |