Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider treating cloudflare:sockets as external in rollupOptions set in @astrojs/cloudflare #407

Closed
1 task done
irvinebroque opened this issue Sep 29, 2024 · 0 comments · Fixed by #409
Closed
1 task done
Assignees
Labels
- P2: has workaround Bug, but has workaround (priority) pkg: cloudflare

Comments

@irvinebroque
Copy link

irvinebroque commented Sep 29, 2024

Describe the Bug

When people try to build Astro apps that use the Postgres.js driver, they see this error at build time:

Error: Cannot resolve "cloudflare:sockets" from "...\node_modules\.pnpm\[email protected]\node_modules\postgres\cf\polyfills.js" and externals are not allowed!

https://x.com/masylum/status/1839743841252905467

Yes — people can fix this in userland by explicitly setting their vite config to treat cloudflare:sockets as external:

vite: {
  ssr: { external: ['node:buffer', 'node:events', 'cloudflare:sockets', 'node:stream' ] },
  build: { rollupOptions: { external: ['cloudflare:sockets'] } },
},

If I understand the adapter correctly, it seems like there is an opportunity here to do this for people automatically, and reduce confusion and take this problem out of userspace?

https://github.com/withastro/adapters/blob/main/packages/cloudflare/src/index.ts#L246

Participation

  • I am willing to submit a pull request for this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) pkg: cloudflare
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants