Esbuild plugin to simplify creation of hybrid (dual) packages that support both ESM and CJS module formats. At version 0.3.4, it automates the generation of wrapper ESM files that re-export CJS module.exports via named exports, addressing reliability issues with Node.js's static analysis for named exports from CJS. The plugin is in PoC status, with frequent releases from the monorepo. It requires esbuild >=0.19.0. Compared to manual dual-package setup or other tools, it offers a minimal, esbuild-native solution with TypeScript support.
npm install esbuild-plugin-hybrid-exportNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: configure esbuild to output CJS in 'target/cjs', while the plugin generates ESM wrappers in 'target/esm' with .mjs extension.
Upgrade esbuild to >=0.19.0.
Ensure esbuild config has format: 'cjs'.
Use explicit named exports in CJS source or test thoroughly.
Pin to a specific version and test upgrades.
Use dynamic import: `const { hybridExportPlugin } = await import('esbuild-plugin-hybrid-export')`Use correct import: `import { hybridExportPlugin } from 'esbuild-plugin-hybrid-export'` or `import hybridExportPlugin from 'esbuild-plugin-hybrid-export'`.