Esbuild plugin (v0.0.11) that extracts CommonJS helper functions (like those from tslib) into a separate shared file, reducing bundle size when multiple CJS modules are emitted. The plugin hooks into esbuild's build process to deduplicate helper injections that esbuild otherwise inlines into each CJS module. Requires esbuild >=0.19.0 as a peer dependency. Currently a PoC with a focused API surface: configure CJS glob pattern, output directory, and helper filename. Ships TypeScript declarations, targets ESM-only consumption.
npm install esbuild-plugin-extract-helpersNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creates the plugin with custom CJS output directory, file inclusion pattern, and helper filename, then invokes esbuild build with CJS format.
Use Node >=12 or upgrade to a version that supports ESM. Alternatively, use dynamic import() from a CommonJS file: import('esbuild-plugin-extract-helpers').then(m => m.extractHelpersPlugin(...))Adjust the `include` option to match your file patterns. For example, set include: /\.js$/
Place the extractHelpersPlugin as the first plugin in the plugins array.
Run `npm install esbuild-plugin-extract-helpers@latest`
Run `npm install esbuild-plugin-extract-helpers` in your project.
Use named import: `import { extractHelpersPlugin } from 'esbuild-plugin-extract-helpers'`Set `format: 'cjs'` in the esbuild build options.