esbuild-plugin-extract-helpers

Esbuild plugin to extract cjs helpers (like tslib)

MIT 10 个版本
安装
npm install esbuild-plugin-extract-helpers
yarn add esbuild-plugin-extract-helpers
pnpm add esbuild-plugin-extract-helpers
bun add esbuild-plugin-extract-helpers
README

esbuild-plugin-extract-helpers

Esbuild plugin to extract cjs helpers (like tslib)

lcov npm

Status

PoC

Problem

By default, esbuild injects helpers into each cjs module. It's fine, when you have just a few, but definitely not when there are many. This plugin extracts helpers into a separate file.

Usage

import { build, BuildOptions } from 'esbuild'
import { extractHelpersPlugin } from 'esbuild-plugin-extract-helpers'

const plugin = extractHelpersPlugin({
  cwd: 'build',         // Optional. Defaults to BuildOptions.outdir || BuildOptions.absWorkingDir
  include: /\.cjs/,     // Optional. Defaults to /./
  helper: 'esblib.cjs'  // Optional. Default value is esblib.cjs
})
const config: BuildOptions = {
  entryPoints: ['index.ts'],
  outdir: 'target/cjs',
  plugins: [plugin],
  format: 'cjs'
}

await build(config)

License

MIT

版本列表
0.0.10 2026-04-13
0.0.8 2026-04-11
0.0.7 2026-04-05
0.0.6 2024-05-26
0.0.5 2024-05-05
0.0.4 2024-05-05
0.0.3 2024-05-03
0.0.2 2024-05-03
0.0.1 2024-05-03
0.0.0 2024-05-03