An esbuild plugin for polyfilling Node.js built-in modules and globals in browser, edge, and Deno environments. Version 0.3.0 is the latest stable release, actively maintained by cyco130. It leverages @jspm/core for polyfills and offers fine-grained control over individual polyfills via options. The plugin includes two variants: polyfillNode for general edge use and polyfillNodeForDeno which uses Deno's std/node library. Key differentiators include support for both Deno and Deno Deploy, configurable globals (Buffer, process, __dirname, __filename), and the ability to disable or replace specific polyfills with empty stubs or npm packages.
npm install esbuild-plugin-polyfill-nodeVerified import paths — ran on the pinned version, not inferred.
Shows how to use polyfillNode plugin with esbuild, disabling Buffer/process globals and enabling crypto/fs polyfills.
Set polyfills: { crypto: true, fs: true } in plugin options.Set globals.buffer: false unless your code explicitly uses Buffer.
Use polyfillNodeForDeno only for Deno Deploy targets; for Deno >=0.178.0 use native node: imports.
Add { polyfills: { crypto: true } } to plugin options.Either set globals.process: true or use esbuild's define option: --define:process.env.NODE_ENV='production'
Enable buffer polyfill: set globals.buffer: true or import 'buffer' polyfill explicitly.