Anyone have luck with tsup esbuild for
Anyone have luck with tsup (esbuild) for building dependencies that use built-ins like Buffer? I've tried a million things to get the usage of a third party tool (passkit-generator).
If I output ESM, I get:
If I output CJS, I get:
I've tried NodeGlobalsPolyfillPlugin and NodeModulesPolyfillPlugin plugins, using node-stdlib-browser, as well as trying to create a shim file. I've tried turning off/on node_compat and setting "type": "module" in my package.json.
My wrangler.toml:
I'm a bit at a loss what else to try to get these imports fixed, any help would be greatly appreaciated.
2 Replies
tsup.config.ts:
fwiw the builds succeed and I've been using tsup/esbuild with other CF Pages apps without issue, but the dependency imports
Buffer
and I'm struggling to polyfill/shim itHey! 👋 Apologies for the delayed response. Just to confirm are you using
wrangler dev --local
? Have you checked the output from tsup is actually including the buffer polyfill? You should only need one of either node_compat
(which only works with Wrangler), or the node modules/globals polyfill.