Detalhes do pacote

esbuild-node-builtin

magicdawn2kMIT0.1.1

esbuild plugin let u use node builtin modules

esbuild, node, node-builtin, node-polyfills

readme (leia-me)

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

changelog (log de mudanças)

CHANGELOG

v0.1.1 2023-07-12

  • chore: remove unused deps
  • feat: add injectGlobal option
  • chore: improve test coverage

v0.1.0 2023-07-12

  • update deps
  • move test to vitest

v0.0.2 2022-12-01

  • move back to polyrepo

v0.0.1 2022-11-30

  • first release