{"id":21938,"library":"rollup-plugin-bundle-esm","title":"rollup-plugin-bundle-esm","description":"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.","status":"active","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/leonzalion/rollup-plugin-bundle-esm","tags":["javascript"],"install":[{"cmd":"npm install rollup-plugin-bundle-esm","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-bundle-esm","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-bundle-esm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; requires Rollup as the bundler.","package":"rollup","optional":false}],"imports":[{"note":"The plugin exports a single default function; named import does not work.","wrong":"import { bundleESM } from 'rollup-plugin-bundle-esm'","symbol":"default","correct":"import bundleESM from 'rollup-plugin-bundle-esm'"},{"note":"CommonJS require gets the default export as the whole module.","wrong":"const { bundleESM } = require('rollup-plugin-bundle-esm')","symbol":"default","correct":"const bundleESM = require('rollup-plugin-bundle-esm')"},{"note":"Type import for TypeScript users; the type is not exported as a value.","wrong":"import { BundleESMOptions } from 'rollup-plugin-bundle-esm'","symbol":"BundleESMOptions","correct":"import type { BundleESMOptions } from 'rollup-plugin-bundle-esm'"}],"quickstart":{"code":"import commonjs from '@rollup/plugin-commonjs';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport { defineConfig } from 'rollup';\nimport bundleESM from 'rollup-plugin-bundle-esm';\n\nexport default defineConfig({\n  output: {\n    format: 'commonjs',\n    dir: 'dist',\n  },\n  input: 'index.js',\n  plugins: [commonjs(), nodeResolve(), bundleESM()],\n});","lang":"typescript","description":"Configures Rollup to bundle only ESM dependencies, leaving CommonJS packages external."},"warnings":[{"fix":"Ensure all dependencies have a 'type' field in their package.json; use 'forceBundle' option to override.","message":"Plugin may not correctly detect package format if package.json is malformed or missing 'type' field. Assumes no 'type' field means CommonJS.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Order plugins: commonjs() first, then nodeResolve(), then bundleESM().","message":"The plugin must be placed after nodeResolve() in the Rollup plugin list to work correctly.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use forceBundle to force bundling of specific packages; do not confuse with external option.","message":"forceBundle option uses the same signature as rollup.external, which may cause confusion between including vs excluding.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Consider alternative plugins or manual external configuration.","message":"Package has not been updated since v0.1.1 (released 2022); may lack compatibility with latest Rollup versions.","severity":"deprecated","affected_versions":"<=0.1.1"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev rollup-plugin-bundle-esm` and ensure import path is correct.","cause":"Package not installed or incorrect import path.","error":"Error: Cannot find module 'rollup-plugin-bundle-esm'"},{"fix":"Use `import bundleESM from 'rollup-plugin-bundle-esm'` instead of `import { bundleESM } from ...`.","cause":"Importing named export instead of default export.","error":"TypeError: bundleESM is not a function"},{"fix":"Manually specify 'forceBundle' for that package: `bundleESM({ forceBundle: ['x'] })`.","cause":"Plugin incorrectly classifies package as CommonJS due to missing 'type' field.","error":"Error: ESM package 'x' was treated as external but should be bundled"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}