A Rollup plugin that automatically bundles only ESM-only dependencies while leaving CommonJS-compatible packages external, optimizing bundle size and reducing edge cases. Current stable version is 0.1.1 (released 2022, no recent updates). Key differentiator: solves the dual-packaging problem for environments without ESM support (e.g., Electron) by specifically targeting ESM packages for inlining, unlike general-purpose resolve plugins that bundle everything. Compatible with Rollup 3+; requires @rollup/plugin-node-resolve and @rollup/plugin-commonjs as companion plugins.
npm install rollup-plugin-bundle-esmVerified import paths — ran on the pinned version, not inferred.
Configures Rollup to bundle only ESM dependencies, leaving CommonJS packages external.
Ensure all dependencies have a 'type' field in their package.json; use 'forceBundle' option to override.
Order plugins: commonjs() first, then nodeResolve(), then bundleESM().
Use forceBundle to force bundling of specific packages; do not confuse with external option.
Consider alternative plugins or manual external configuration.
Run `npm install --save-dev rollup-plugin-bundle-esm` and ensure import path is correct.
Use `import bundleESM from 'rollup-plugin-bundle-esm'` instead of `import { bundleESM } from ...`.Manually specify 'forceBundle' for that package: `bundleESM({ forceBundle: ['x'] })`.