0.0.6 • Published 1 year ago

esbuild-plugin-extract-helpers v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago