esbuild-node-builtin
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

esbuild-node-builtin

esbuild plugin let u use node builtin modules

Build Status Coverage Status npm version npm downloads npm license

Install

$ pnpm add -D esbuild-node-builtin

Usage

import { nodeBuiltin } from 'esbuild-node-builtin'

esbuild.build({
  // blabla
  plugins: [nodeBuiltin()],
})

Options

  • injectGlobal: use esbuild inject for global reference, default true
  • injectProcess: use esbuild inject for process global reference, default true
  • injectBuffer: use esbuild inject for Buffer global reference, default false, since this is big AND can not perform tree-shaking
  • exclude: string[], disable proxy some builtin module

inject*

see https://esbuild.github.io/api/#inject

injectGlobal

make global.variable = 'value' works in environment has no global, basicly translate to globalThis.variable = 'value'

Why

there are existing packages

AND

rollup-plugin-polyfill-node

rollup-plugin-polyfill-node looks great, resolves to esm modules, and tree-shakable. but is for rollup.

esbuild-plugin-polyfill-node

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

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

Why depends on rollup

this package depends on rollup-plugin-polyfill-node, and use it's internal bundled polyfills. the rollup dep is useless, just prevent error report.

Changelog

CHANGELOG.md

License

the MIT License http://magicdawn.mit-license.org

Package Sidebar

Install

npm i esbuild-node-builtin

Weekly Downloads

12

Version

0.1.1

License

MIT

Unpacked Size

12.1 kB

Total Files

8

Last publish

Collaborators

  • magicdawn