esbuild-plugins-node-modules-polyfill
Polyfills nodejs builtin modules for the browser.
Description
Polyfills nodejs builtin modules and globals for the browser.
Features
- Written In Typescript
- Offers CJS and ESM builds
- Full TypeScript & JavaScript support
- Supports
node:
protocol - Optionally injects globals
Install
npm install --save-dev esbuild-plugins-node-modules-polyfill
Usage
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [nodeModulesPolyfillPlugin()],
});
Optionally configure which modules to polyfill:
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [nodeModulesPolyfillPlugin({
modules: ['crypto'],
})],
});
Optionally inject globals when detected:
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill';
import { build } from 'esbuild';
build({
plugins: [nodeModulesPolyfillPlugin({
globals: {
process: true,
Buffer: true,
}
})],
});
Buy me some doughnuts
If you want to support me by donating, you can do so by using any of the following methods. Thank you very much in advance!
Contributors ✨
Thanks goes to these wonderful people: