From 054c5c6447d79dd4ea7ab6ce0f9ec836abebd211 Mon Sep 17 00:00:00 2001 From: Jonathan Dunlap <595843+jadbox@users.noreply.github.com> Date: Mon, 9 Oct 2023 13:13:46 -0400 Subject: [PATCH] fix(cloudflare): support for 'cloudflare:*' imports (#8766) * chore: add 'cloudflare:sockets' to external list * chore: add Changeset * patch: wildcard cloudflare packages * chore: updated Readme for cloudflare module support * Update .changeset/heavy-elephants-tan.md Co-authored-by: Sarah Rainsberger * Update packages/integrations/cloudflare/README.md Co-authored-by: Sarah Rainsberger --------- Co-authored-by: Sarah Rainsberger Co-authored-by: Alexander Niebuhr --- .changeset/heavy-elephants-tan.md | 5 +++++ packages/integrations/cloudflare/README.md | 4 ++++ packages/integrations/cloudflare/src/index.ts | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 .changeset/heavy-elephants-tan.md diff --git a/.changeset/heavy-elephants-tan.md b/.changeset/heavy-elephants-tan.md new file mode 100644 index 000000000..4dc2b8579 --- /dev/null +++ b/.changeset/heavy-elephants-tan.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Adds `cloudflare:sockets` compile support diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 10a381a7b..a72e2f1d4 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -357,6 +357,10 @@ import { Buffer } from 'node:buffer'; 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. For detailed guidance, please refer to the [Cloudflare documentation on enabling Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs). +## Cloudflare module support + +All Cloudflare namespaced packages (e.g. `cloudflare:sockets`) are allowlisted for use. Note that the package `cloudflare:sockets` does not work locally without using Wrangler dev mode. + ## Preview with Wrangler To use [`wrangler`](https://developers.cloudflare.com/workers/wrangler/) to run your application locally, update the preview script: diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 59cd92ce3..c0da2dd74 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -290,6 +290,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:stream', 'node:string_decoder', 'node:util', + 'cloudflare:*' ], entryPoints: pathsGroup, outbase: absolutePagesDirname, @@ -371,6 +372,7 @@ export default function createIntegration(args?: Options): AstroIntegration { 'node:stream', 'node:string_decoder', 'node:util', + 'cloudflare:*' ], entryPoints: [entryPath], outfile: buildPath,