Skip to content

Conversation

@CHC383
Copy link
Contributor

@CHC383 CHC383 commented Jun 3, 2025

close #3452

Conditional export was chosen as the fix to align with the previous solution #2978, however this does require the consumers to explicitly resolve the condition to cloudflare in their bundler's config with some extra setup, which might be considered as a breaking change.

A private package pg-bundler-test is also created to test the bundling case. It will be run through yarn test and test webpack, vite (uses rollup underneath), rollup and esbuild to bundle the code that imports pg-cloudflare. webpack, vite and rollup are all having problems bundling cloudflare:sockets if not specifically exclude/ignore it, while esbuild works fine. These are the top bundlers on my head, other examples and tests could be added later.

I didn't update docs as I searched for cloudflare on node-postgres.com and didn't find anything, so I am not sure where is the right place. Hopefully the README of pg-cloudflare is good enough, and feel free to add more docs if necessary.

Note: Vite 5+ requires Node 18+, so the Vite bundler test is skipped on Node 16, see the vite script in the package.json for the details.

@CHC383 CHC383 marked this pull request as draft June 3, 2025 03:00
@CHC383 CHC383 marked this pull request as ready for review June 3, 2025 03:26
@CHC383 CHC383 marked this pull request as draft June 3, 2025 06:31
@CHC383 CHC383 marked this pull request as ready for review June 3, 2025 07:16
@brianc
Copy link
Owner

brianc commented Jun 12, 2025

This is absolutely, super helpful. Thank you so much 🎉

@brianc brianc merged commit 6b016b3 into brianc:master Jun 12, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets" when bundling with Webpack

2 participants