Skip to content

Commit

Permalink
fix(cloudflare): support for 'cloudflare:*' imports (#8766)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update packages/integrations/cloudflare/README.md

Co-authored-by: Sarah Rainsberger <[email protected]>

---------

Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Alexander Niebuhr <[email protected]>
  • Loading branch information
3 people authored Oct 9, 2023
1 parent 7ea27f6 commit 054c5c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-elephants-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

Adds `cloudflare:sockets` compile support
4 changes: 4 additions & 0 deletions packages/integrations/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
'node:stream',
'node:string_decoder',
'node:util',
'cloudflare:*'
],
entryPoints: pathsGroup,
outbase: absolutePagesDirname,
Expand Down Expand Up @@ -371,6 +372,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
'node:stream',
'node:string_decoder',
'node:util',
'cloudflare:*'
],
entryPoints: [entryPath],
outfile: buildPath,
Expand Down

0 comments on commit 054c5c6

Please sign in to comment.