Polyfill node builtin modules with esbuild
.
yarn add -D esbuild-plugin-node-builtin-polyfills
or
npm i -D esbuild-plugin-node-builtin-polyfills
Add to your esbuild plugins list:
const esbuild = require("esbuild");
const { nodeBuiltInPolyfillsPlugin } = require("esbuild-plugin-node-builtin-polyfills");
esbuild.build({
...
plugins: [
nodeBuiltInPolyfillsPlugin()
]
...
});