{"id":25302,"library":"esbuild-node-builtin","title":"esbuild-node-builtin","description":"esbuild plugin to polyfill Node.js built-in modules when bundling for the browser. Version 0.1.1, stable but rarely updated. Integrates polyfills from rollup-plugin-polyfill-node with tree-shaking support, unlike alternatives that include entire modules. It uses esbuild's inject API to handle globals like 'global', 'process', and optionally 'Buffer'. Requires esbuild as a peer dependency and uses rollup-plugin-polyfill-node internally (a no-op dependency to avoid errors).","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/magicdawn/esbuild-node-builtin","tags":["javascript","esbuild","node","node-builtin","node-polyfills","polyfills-node","polyfills","browserify","typescript"],"install":[{"cmd":"npm install esbuild-node-builtin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-node-builtin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-node-builtin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for the plugin to work","package":"esbuild","optional":false},{"reason":"Internal dependency for polyfills, but rollup is not actually needed at runtime","package":"rollup-plugin-polyfill-node","optional":true}],"imports":[{"note":"Exported as named export only; default import will not work.","wrong":"import nodeBuiltin from 'esbuild-node-builtin'","symbol":"nodeBuiltin","correct":"import { nodeBuiltin } from 'esbuild-node-builtin'"},{"note":"CJS require destructuring is required; plain require returns an object with the named export.","wrong":"const nodeBuiltin = require('esbuild-node-builtin')","symbol":"nodeBuiltin","correct":"const { nodeBuiltin } = require('esbuild-node-builtin')"},{"note":"Type import for the options interface; only needed with TypeScript.","wrong":"","symbol":"EsbuildNodeBuiltinOptions","correct":"import type { EsbuildNodeBuiltinOptions } from 'esbuild-node-builtin'"}],"quickstart":{"code":"import { nodeBuiltin } from 'esbuild-node-builtin';\nimport esbuild from 'esbuild';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  platform: 'browser',\n  plugins: [nodeBuiltin()],\n});","lang":"typescript","description":"Demonstrates basic usage of the plugin with esbuild bundling for browser, using default options to polyfill 'global' and 'process'."},"warnings":[{"fix":"Ignore the rollup dependency; it is used only internally. Do not install rollup unless required for other projects.","message":"The package depends on rollup-plugin-polyfill-node, but rollup is not actually needed at runtime. This can cause confusion if you try to install rollup as a dependency.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Only set injectBuffer: true if you absolutely need the Buffer global and accept the size cost.","message":"The 'injectBuffer' option is disabled by default because it is large and not tree-shakable. Enabling it may significantly increase bundle size.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Check the README on GitHub for the latest API if upgrading.","message":"The 'exclude' option uses a string array to disable proxying certain builtins. This API may change in future versions.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure rollup-plugin-polyfill-node is installed (it is a regular dependency, not optional). Run: pnpm add -D esbuild-node-builtin or npm install esbuild-node-builtin --save-dev","cause":"The package has a dependency on rollup-plugin-polyfill-node, which may not be installed if using a strict package manager or if node_modules are pruned.","error":"Error: Cannot find module 'rollup-plugin-polyfill-node'"},{"fix":"Use named import: import { nodeBuiltin } from 'esbuild-node-builtin'","cause":"Using a default import instead of a named import.","error":"TypeError: esbuild_node_builtin_1.nodeBuiltin is not a function"},{"fix":"Invoke the function: plugins: [nodeBuiltin()]","cause":"Attempting to use the plugin without calling the factory function, e.g. plugins: [nodeBuiltin] instead of plugins: [nodeBuiltin()].","error":"Error: The plugin \"esbuild-node-builtin\" is not a function"},{"fix":"Check if the builtin is polyfilled; if not, use a separate polyfill package and add to the 'exclude' option to avoid double bundling.","cause":"The plugin may not cover all Node builtins, or the builtin is not polyfilled by default.","error":"Error: Build failed with 1 error: error: Could not resolve \"crypto\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}