porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.04k stars 257 forks source link

docs: update Cloudflare Workers instructions #796

Closed Cherry closed 5 months ago

Cherry commented 5 months ago

With Cloudflare Workers, node_compat is an old paradigm that injects a lot of things into the global namespace that aren't necessary here, and existed before Cloudflare had more native support for Node.js APIs.

nodejs_compat is much more modern and Cloudflare's solution for actually using Node.js modules, and what this library uses when it imports from things like node:events, etc.

The tests referenced for the Cloudflare implementation here also use nodejs_compat, not node_compat: https://github.com/porsager/postgres/blob/6f20a4820c683b33e7670b606d8daf5670f4b973/cf/test.js#L2

I've tested with many of my own projects, and only nodejs_compat is needed. You in fact can't use both the older node_compat and newer nodejs_compat, so I would recommend encouraging use of the newer paradigm here.