Skip to content

fix(pg-cloudflare): use conditional export to support bundlers that d… #3482

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CHC383
Copy link

@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 force-pushed the fix/webpack-bundle branch 2 times, most recently from ff3de4a to cf08852 Compare June 3, 2025 03:20
@CHC383 CHC383 marked this pull request as ready for review June 3, 2025 03:26
@CHC383 CHC383 force-pushed the fix/webpack-bundle branch from cf08852 to c1b7b6b Compare June 3, 2025 06:18
@CHC383 CHC383 marked this pull request as draft June 3, 2025 06:31
@CHC383 CHC383 force-pushed the fix/webpack-bundle branch from c1b7b6b to 8742fd2 Compare June 3, 2025 07:10
@CHC383 CHC383 marked this pull request as ready for review June 3, 2025 07:16
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
1 participant