esbuild plugin let u use node builtin modules
npm install esbuild-node-builtin> esbuild plugin let u use node builtin modules





``sh`
$ pnpm add -D esbuild-node-builtin
`ts
import { nodeBuiltin } from 'esbuild-node-builtin'
esbuild.build({
// blabla
plugins: [nodeBuiltin()],
})
`
- injectGlobal: use esbuild inject for global reference, default trueinjectProcess
- : use esbuild inject for process global reference, default trueinjectBuffer
- : use esbuild inject for Buffer global reference, default false, since this is big AND can not perform tree-shakingexclude
- : string[], disable proxy some builtin module
see https://esbuild.github.io/api/#inject
#### injectGlobal
make global.variable = 'value' works in environment has no global, basicly translate to globalThis.variable = 'value'
there are existing packages
- https://github.com/FredKSchott/rollup-plugin-polyfill-node
- https://github.com/cyco130/esbuild-plugin-polyfill-node
AND
rollup-plugin-polyfill-node looks great, resolves to esm modules, and tree-shakable. but is for rollup.
esbuild-plugin-polyfill-node is a esbuild plugin.
- AND use browserify commonjs deps. AND not tree-shakable
- UPDATE: 2023-07, it uses @jspm/core, same not well tree-shakable, e.g path these lines are side effects, and not tree-shakable
e.g
`ts``
import { format } from 'util'
- this package & rollup-plugin-polyfill-node, other exports from util will not be included.
- esbuild-plugin-polyfill-node will include entire util.js
this package depends on rollup-plugin-polyfill-node, and use it's internal bundled polyfills.
the rollup dep is useless, just prevent error report.
the MIT License http://magicdawn.mit-license.org