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:

[mf:err] Error: Dynamic require of "buffer" is not supported


If I output CJS, I get:

▲ [WARNING] Converting "require" to "esm" is currently not supported [unsupported-require-call]

    dist/index.cjs:28310:21:
      28310 │ var import_buffer4 = require("buffer");


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:

name = "..."
main = "./dist/index.js"
account_id = "..."
workers_dev = true
compatibility_date = "2022-11-08"
node_compat = true
usage_model = "unbound"

[build]
command = "npm run build"
watch_dir = ["src"]


I'm a bit at a loss what else to try to get these imports fixed, any help would be greatly appreaciated.
Was this page helpful?