Skip to content

Commit 090804c

Browse files
fix(docs): conform to astro md processor reqs
Signed-off-by: Cameron Smith <cameron.ray.smith@gmail.com>
1 parent 817b320 commit 090804c

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

packages/docs/src/content/docs/notes/build/rolldown-workers-incompatibility.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Rolldown-Vite Integration (Currently Disabled)
1+
---
2+
title: Rolldown-Vite Integration (Currently Disabled)
3+
---
24

35
## Status
46

@@ -11,9 +13,11 @@
1113
## Issue Details
1214

1315
### Problem
16+
1417
Rolldown's bundler generates runtime code that uses Node.js's `createRequire(import.meta.url)`, which fails in Cloudflare Workers because `import.meta.url` is undefined in that execution context.
1518

1619
### Error
20+
1721
```
1822
✘ [ERROR] service core:user:typescript-nix-template: Uncaught TypeError:
1923
The argument 'path' must be a file URL object, a file URL string, or an absolute path string.
@@ -26,16 +30,19 @@ at null.<anonymous> (index.js:1203:33) in dist/_worker.js/chunks/rolldown-runtim
2630
### Investigation Results
2731

2832
**GitHub Issues & PRs**:
29-
- Issue: https://github.com/cloudflare/workers-sdk/issues/9415 (Closed)
30-
- Fix Merged: https://github.com/cloudflare/workers-sdk/pull/9891 (July 18, 2025)
33+
34+
- Issue: <https://github.com/cloudflare/workers-sdk/issues/9415> (Closed)
35+
- Fix Merged: <https://github.com/cloudflare/workers-sdk/pull/9891> (July 18, 2025)
3136

3237
**Root Cause**:
38+
3339
- The fix in PR #9891 sets `rollupOptions.platform: "neutral"` to prevent rolldown's Node.js polyfills
3440
- **Critical limitation**: The fix only applies to `@cloudflare/vite-plugin`, not `@astrojs/cloudflare`
3541
- We use `@astrojs/cloudflare` adapter which internally manages Vite configuration
3642
- No direct way to apply the platform: "neutral" fix through Astro's adapter layer
3743

3844
**Attempted Workarounds** (all unsuccessful):
45+
3946
1. Setting `vite.build.rollupOptions.platform: "neutral"` in astro.config.mjs
4047
2. Setting `vite.ssr.build.rollupOptions.platform: "neutral"`
4148
3. Setting `vite.optimizeDeps.esbuildOptions.platform: "neutral"`
@@ -49,11 +56,13 @@ When rolldown compatibility is resolved with Astro + Cloudflare, follow these st
4956
### Step 1: Update package.json
5057

5158
Add to `devDependencies`:
59+
5260
```json
5361
"vite": "npm:rolldown-vite@latest"
5462
```
5563

5664
Add new `overrides` section at root level:
65+
5766
```json
5867
"overrides": {
5968
"vite": "npm:rolldown-vite@latest"
@@ -63,6 +72,7 @@ Add new `overrides` section at root level:
6372
### Step 2: Update astro.config.mjs
6473

6574
1. Uncomment the vite import at the top:
75+
6676
```javascript
6777
import * as vite from "vite";
6878
```
@@ -86,43 +96,51 @@ bun run preview
8696
```
8797

8898
**Success Criteria**:
99+
89100
- Build completes without errors
90101
- No `createRequire` in `dist/_worker.js/chunks/rolldown-runtime_*.mjs`
91102
- Wrangler dev starts successfully
92-
- Site loads at http://localhost:8787
103+
- Site loads at <http://localhost:8787>
93104

94105
## Alternative Paths Forward
95106

96107
### Option A: Wait for Official Support
97-
- Monitor Astro + Rolldown roadmap: https://github.com/rolldown/rolldown/discussions/153
108+
109+
- Monitor Astro + Rolldown roadmap: <https://github.com/rolldown/rolldown/discussions/153>
98110
- Currently "on hold" for Astro support
99-
- Subscribe to: https://github.com/withastro/adapters/issues
111+
- Subscribe to: <https://github.com/withastro/adapters/issues>
100112

101113
### Option B: Migrate to @cloudflare/vite-plugin
114+
102115
If Astro adds support for using `@cloudflare/vite-plugin` directly:
103116

104117
**Pros**:
118+
105119
- Direct access to rolldown compatibility fixes
106120
- Native Workers runtime in dev server
107121
- Official Cloudflare support
108122

109123
**Cons**:
124+
110125
- Would lose Astro-specific adapter features
111126
- Significant configuration changes required
112127
- Unknown SSR parity with `@astrojs/cloudflare`
113128

114129
**Resources**:
115-
- https://developers.cloudflare.com/workers/vite-plugin/
116-
- https://blog.cloudflare.com/introducing-the-cloudflare-vite-plugin/
130+
131+
- <https://developers.cloudflare.com/workers/vite-plugin/>
132+
- <https://blog.cloudflare.com/introducing-the-cloudflare-vite-plugin/>
117133

118134
## Performance Comparison
119135

120136
**Standard Vite** (current):
137+
121138
- Server build: ~900ms
122139
- Client build: ~34ms
123140
- Total: ~1.6s
124141

125142
**Rolldown-Vite** (when tested):
143+
126144
- Server build: ~890ms (similar)
127145
- Client build: ~33ms (similar)
128146
- Total: ~1.6s
@@ -133,6 +151,7 @@ Reference projects report 2-16x improvements.
133151
## Dependencies
134152

135153
The `@astrojs/cloudflare` adapter currently depends on:
154+
136155
```json
137156
{
138157
"@cloudflare/workers-types": "^4.20250109.0",

0 commit comments

Comments
 (0)