Registry / devops / rollup-plugin-bundle-esm

rollup-plugin-bundle-esm

JSON →
library0.1.1jsnpmunverified

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-esm
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-BUND
R
rollup-plugin-bundle-esm
devopsjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import bundleESM from 'rollup-plugin-bundle-esm'
import { bundleESM } from 'rollup-plugin-bundle-esm'
The plugin exports a single default function; named import does not work.
default
const bundleESM = require('rollup-plugin-bundle-esm')
const { bundleESM } = require('rollup-plugin-bundle-esm')
CommonJS require gets the default export as the whole module.
BundleESMOptions
import type { BundleESMOptions } from 'rollup-plugin-bundle-esm'
import { BundleESMOptions } from 'rollup-plugin-bundle-esm'
Type import for TypeScript users; the type is not exported as a value.

Configures Rollup to bundle only ESM dependencies, leaving CommonJS packages external.

import commonjs from '@rollup/plugin-commonjs'; import { nodeResolve } from '@rollup/plugin-node-resolve'; import { defineConfig } from 'rollup'; import bundleESM from 'rollup-plugin-bundle-esm'; export default defineConfig({ output: { format: 'commonjs', dir: 'dist', }, input: 'index.js', plugins: [commonjs(), nodeResolve(), bundleESM()], });
Debug
Known issues
gotchaPlugin may not correctly detect package format if package.json is malformed or missing 'type' field. Assumes no 'type' field means CommonJS.
fix
Ensure all dependencies have a 'type' field in their package.json; use 'forceBundle' option to override.
affects: >=0.1.0
gotchaThe plugin must be placed after nodeResolve() in the Rollup plugin list to work correctly.
fix
Order plugins: commonjs() first, then nodeResolve(), then bundleESM().
affects: >=0.1.0
gotchaforceBundle option uses the same signature as rollup.external, which may cause confusion between including vs excluding.
fix
Use forceBundle to force bundling of specific packages; do not confuse with external option.
affects: >=0.1.0
deprecatedPackage has not been updated since v0.1.1 (released 2022); may lack compatibility with latest Rollup versions.
fix
Consider alternative plugins or manual external configuration.
affects: <=0.1.1
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-bundle-esm'
Package not installed or incorrect import path.
fix
Run `npm install --save-dev rollup-plugin-bundle-esm` and ensure import path is correct.
TypeError: bundleESM is not a function
Importing named export instead of default export.
fix
Use `import bundleESM from 'rollup-plugin-bundle-esm'` instead of `import { bundleESM } from ...`.
Error: ESM package 'x' was treated as external but should be bundled
Plugin incorrectly classifies package as CommonJS due to missing 'type' field.
fix
Manually specify 'forceBundle' for that package: `bundleESM({ forceBundle: ['x'] })`.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
rolluprequiredPeer dependency; requires Rollup as the bundler.
Agent activity
7 hits · last 30 days
node
6
Resources