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.
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.
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 likenode:events
, etc.The tests referenced for the Cloudflare implementation here also use
nodejs_compat
, notnode_compat
: https://github.com/porsager/postgres/blob/6f20a4820c683b33e7670b606d8daf5670f4b973/cf/test.js#L2I've tested with many of my own projects, and only
nodejs_compat
is needed. You in fact can't use both the oldernode_compat
and newernodejs_compat
, so I would recommend encouraging use of the newer paradigm here.