@astrojs/cloudflare 7.1.1 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +27 -0
  2. package/dist/index.js +24 -0
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -202,6 +202,33 @@ This will enable Cloudflare to serve files and process static redirects without
202
202
 
203
203
  See [Cloudflare's documentation](https://developers.cloudflare.com/pages/platform/functions/routing/#create-a-_routesjson-file) for more details.
204
204
 
205
+ ## Node.js compatibility
206
+
207
+ Astro's Cloudflare adapter allows you to use any Node.js runtime API supported by Cloudflare:
208
+
209
+ - assert
210
+ - AsyncLocalStorage
211
+ - Buffer
212
+ - Diagnostics Channel
213
+ - EventEmitter
214
+ - path
215
+ - process
216
+ - Streams
217
+ - StringDecoder
218
+ - util
219
+
220
+ To use these APIs, your page or endpoint must be server-side rendered (not pre-rendered) and must use the the `import {} from 'node:*'` import syntax.
221
+
222
+ ```js
223
+ // pages/api/endpoint.js
224
+ export const prerender = false;
225
+ import { Buffer } from 'node:buffer';
226
+ ```
227
+
228
+ Additionally, you'll need to enable the Compatibility Flag in Cloudflare. The configuration for this flag may vary based on where you deploy your Astro site.
229
+
230
+ For detailed guidance, please refer to the [Cloudflare documentation](https://developers.cloudflare.com/workers/runtime-apis/nodejs).
231
+
205
232
  ## Troubleshooting
206
233
 
207
234
  For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
package/dist/index.js CHANGED
@@ -241,6 +241,18 @@ function createIntegration(args) {
241
241
  target: "es2020",
242
242
  platform: "browser",
243
243
  conditions: ["workerd", "worker", "browser"],
244
+ external: [
245
+ "node:assert",
246
+ "node:async_hooks",
247
+ "node:buffer",
248
+ "node:diagnostics_channel",
249
+ "node:events",
250
+ "node:path",
251
+ "node:process",
252
+ "node:stream",
253
+ "node:string_decoder",
254
+ "node:util"
255
+ ],
244
256
  entryPoints: entryPaths,
245
257
  outdir: outputDir,
246
258
  allowOverwrite: true,
@@ -287,6 +299,18 @@ function createIntegration(args) {
287
299
  target: "es2020",
288
300
  platform: "browser",
289
301
  conditions: ["workerd", "worker", "browser"],
302
+ external: [
303
+ "node:assert",
304
+ "node:async_hooks",
305
+ "node:buffer",
306
+ "node:diagnostics_channel",
307
+ "node:events",
308
+ "node:path",
309
+ "node:process",
310
+ "node:stream",
311
+ "node:string_decoder",
312
+ "node:util"
313
+ ],
290
314
  entryPoints: [entryPath],
291
315
  outfile: buildPath,
292
316
  allowOverwrite: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to Cloudflare Workers/Pages",
4
- "version": "7.1.1",
4
+ "version": "7.2.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -44,7 +44,7 @@
44
44
  "@astrojs/underscore-redirects": "0.3.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "astro": "^3.1.1"
47
+ "astro": "^3.1.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/iarna__toml": "^2.0.2",
@@ -53,7 +53,7 @@
53
53
  "kill-port": "^2.0.1",
54
54
  "mocha": "^10.2.0",
55
55
  "wrangler": "^3.5.1",
56
- "astro": "3.1.1",
56
+ "astro": "3.1.2",
57
57
  "astro-scripts": "0.0.14"
58
58
  },
59
59
  "scripts": {