Can Workers Function use npm packages that use node apis?
I want to use the npm package thirty-two (https://www.npmjs.com/package/thirty-two). It was last published 7 years ago seems to use the Buffer api in node.
In wrangler.toml, setting
compatibility_flags = [ "nodejs_compat" ]
was not enough. I also had to mutate globalThis.
Is there a cleaner way to do this? What is the recommended approach to using npm packages that use node apis without an import with the node specifier (eg. import { Buffer } from 'node:buffer
)
0 Replies