adapters
adapters copied to clipboard
Cloudflare v10 breaks cloudflare build / wrangler preview with `imageService: "compile"` and Astro's `<Image />` component
Astro Info
Astro v4.5.12
Node v20.12.0
System Windows (x64)
Package Manager npm
Output hybrid
Adapter @astrojs/cloudflare
Integrations @astrojs/react
Describe the Bug
When using v10 version of the adapter, hybrid output mode and <Image/> component on a prerendered path, with combination of imageService: "compile" in the configuration, wrangler preview fails. This was not the case with previous version, it looks like there are modules being bundled which should not be bundler.
Steps to reproduce
- npm run build-and-preview
Attaching additional modules:
┌──────────────────────────────────────────┬──────┬───────────┐
│ Name │ Type │ Size │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/astro/assets-service_Dj66YdWb.mjs │ esm │ 12.29 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/astro_DBzb2nRr.mjs │ esm │ 83.90 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/image-endpoint_RvDj3-CK.mjs │ esm │ 0.18 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/index_B6euTALA.mjs │ esm │ 0.18 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/pages/image-endpoint_nxDOIah1.mjs │ esm │ 0.06 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/pages/index_CPLiUgeG.mjs │ esm │ 0.20 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/prerender_H0Lv92GL.mjs │ esm │ 0.09 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/test_2VqMiBwm.mjs │ esm │ 0.17 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ chunks/vnode-children_VTcTc4QR.mjs │ esm │ 2.94 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ manifest_BEhMcueP.mjs │ esm │ 18.13 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ renderers.mjs │ esm │ 85.67 KiB │
├──────────────────────────────────────────┼──────┼───────────┤
│ _noop-middleware.mjs │ esm │ 0.12 KiB │
└──────────────────────────────────────────┴──────┴───────────┘
✨ Compiled Worker successfully
⛅️ wrangler 3.39.0
-------------------
[wrangler:inf] Ready on http://127.0.0.1:4321
X [ERROR] Could not resolve "child_process"
node_modules/detect-libc/lib/detect-libc.js:6:29:
6 │ const childProcess = require('child_process');
╵ ~~~~~~~~~~~~~~~
The package "child_process" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
X [ERROR] Could not resolve "fs"
node_modules/detect-libc/lib/filesystem.js:6:19:
6 │ const fs = require('fs');
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
X [ERROR] Could not resolve "util"
node_modules/sharp/lib/constructor.js:6:21:
6 │ const util = require('util');
╵ ~~~~~~
The package "util" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
X [ERROR] Could not resolve "stream"
node_modules/sharp/lib/constructor.js:7:23:
7 │ const stream = require('stream');
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
... more errors
What's the expected result?
imageService: "compile" should not break the ouputted build for Cloudflare.
Link to Minimal Reproducible Example
https://github.com/dallyh/astro-cf-10-issues/tree/image-service-compile
Participation
- [ ] I am willing to submit a pull request for this issue.