-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Astro v6 with cloudflare adapter does not work with <Code ...> components #15284
Description
Astro Info
Astro v6.0.0-beta.2
Vite v7.3.1
Node v24.10.0
System macOS (arm64)
Package Manager npm
Output static
Adapter @astrojs/cloudflare (v13.0.0-beta.1)
Integrations @astrojs/mdx (v5.0.0-beta.1)
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
With the v6/v13 astro/cloudflare beta, any <Code> components in mdx files rendered are broken. When rendering an MDX file with the <Code component, an error is raised. When rendering an MDX file without it, everything works fine.
The reproduction is just the blog starter with minimal changes to show the issue. I encountered the same issue in my production Astro app after trying out v6. It only seems to break in the dev server. When build/preview-ing it seems to work just fine.
Below is the error.
> npm run dev
> dev
> astro dev
12:10:25 [@astrojs/cloudflare] Enabling image processing with Cloudflare Images for production with the "IMAGES" Images binding.
12:10:25 [@astrojs/cloudflare] Enabling sessions with Cloudflare KV with the "SESSION" KV binding.
12:10:25 [WARN] [vite] Default inspector port 9229 not available, using 9230 instead
12:10:25 [vite] Re-optimizing dependencies because lockfile has changed
12:10:26 [types] Generated 1ms
[vite] connected.
12:10:26 [content] Syncing content
12:10:26 [content] Synced content
12:10:26 [vite] Re-optimizing dependencies because lockfile has changed
12:10:26 [vite] Port 4321 is in use, trying another one...
astro v6.0.0-beta.2 ready in 2180 ms
┃ Local http://localhost:4322/
┃ Network use --host to expose
▶ This is a beta prerelease build!
Report issues here: https://astro.build/issues
12:10:26 watching for file changes...
12:10:50 [vite] ✨ new dependencies optimized: astro/content/runtime, astro/zod
12:10:50 [vite] ✨ optimized dependencies changed. reloading
12:10:50 [vite] [vite] program reload
12:10:51 [vite] ✨ new dependencies optimized: astro/jsx-runtime
12:10:51 [vite] ✨ optimized dependencies changed. reloading
12:10:51 [vite] [vite] program reload
12:14:33 [vite] ✨ new dependencies optimized: astro/components
12:14:33 [vite] ✨ optimized dependencies changed. reloading
12:14:33 [vite] [vite] program reload
12:14:35 [ERROR] [vite] 12:14:35 [ERROR] ReferenceError: module is not defined
at /Users/alexherrmann/git/mine-current/astrov6-personal-site/node_modules/debug/src/index.js:7:2
at Object.runInlinedModule (workers/runner-worker.js:1314:56)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
12:14:35 [ERROR] [vite] Internal server error: module is not defined
at null.<anonymous> (/Users/alexherrmann/git/mine-current/astrov6-personal-site/node_modules/debug/src/index.js:7:2)
at Object.runInlinedModule (workers/runner-worker.js:1314:56)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
12:15:03 [glob-loader] Reloaded data from typescript-tips.mdx
12:15:03 [ERROR] [vite] 12:15:03 [ERROR] ReferenceError: module is not defined
at /Users/alexherrmann/git/mine-current/astrov6-personal-site/node_modules/debug/src/index.js:7:2
at Object.runInlinedModule (workers/runner-worker.js:1314:56)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
12:15:03 [ERROR] [vite] Internal server error: module is not defined
at null.<anonymous> (/Users/alexherrmann/git/mine-current/astrov6-personal-site/node_modules/debug/src/index.js:7:2)
at Object.runInlinedModule (workers/runner-worker.js:1314:56)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
12:15:04 [ERROR] [vite] 12:15:04 [ERROR] ReferenceError: module is not defined
at /Users/alexherrmann/git/mine-current/astrov6-personal-site/node_modules/debug/src/index.js:7:2
at Object.runInlinedModule (workers/runner-worker.js:1314:56)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
12:15:04 [ERROR] [vite] Internal server error: module is not defined
at null.<anonymous> (/Users/alexherrmann/git/mine-current/astrov6-personal-site/node_modules/debug/src/index.js:7:2)
at Object.runInlinedModule (workers/runner-worker.js:1314:56)
at CustomModuleRunner.directRequest (workers/runner-worker.js:1166:80)
at CustomModuleRunner.cachedRequest (workers/runner-worker.js:1084:73)
I am happy to submit a pull request, but it looks like the error may be in the cloudflare workers-sdk repo (the vite plugin)? I haven't dug deep enough to know if it's a misconfiguration on Astro's end, or a bug in that code.
What's the expected result?
No error, and the <Code element should correctly render.
Link to Minimal Reproducible Example
https://github.com/alexmherrmann/astro6cloudflare13-bug
Participation
- I am willing to submit a pull request for this issue.