babelrc-rollup
raw JSON → 3.0.0 verified Sat Apr 25 auth: no javascript maintenance
Builds a Babel configuration for rollup-plugin-babel by reading a .babelrc file. Current stable version is 3.0.0 (August 2016, no recent updates). It simplifies Rollup integration by automatically converting presets to Rollup-compatible versions (e.g., es2015 → es2015-rollup) and adding the external-helpers plugin. Unlike manual configuration, it reads .babelrc and handles preset option passing (array syntax) for Babel v6.13+. Key differentiator: removes manual setup for Rollup+Babel, but is largely superseded by Rollup's built-in Babel handling.
Common errors
error Error: Cannot find module 'babel-preset-es2015-rollup' ↓
cause findRollupPresets enabled but the corresponding -rollup preset is not installed.
fix
Install the -rollup preset: npm install --save-dev babel-preset-es2015-rollup, or disable findRollupPresets.
error Error: .babelrc file not found ↓
cause The default path '.babelrc' does not exist or is not readable.
fix
Ensure a .babelrc file exists at the project root, or pass a custom path option to babelrc().
error TypeError: babelrc is not a function ↓
cause Wrong import style or version incompatibility (require instead of import or ES module mismatch).
fix
Use the default import: import babelrc from 'babelrc-rollup';
Warnings
breaking v3.0.0: findRollupPresets default changed from true to false. If you relied on automatic -rollup preset resolution, you must explicitly set findRollupPresets: true. ↓
fix Add findRollupPresets: true to the options object passed to babelrc().
breaking v2.0.0: findRollupPresets scans all presets for a -rollup suffix, which may pick up unintended replacements. ↓
fix Explicitly set findRollupPresets to false if you want exact preset matching, or upgrade to v3.0.0+.
deprecated The package is effectively unmaintained since August 2016. Modern Rollup and Babel versions may not work correctly. ↓
fix Consider using @rollup/plugin-babel with manual babel config or @babel/preset-env's modules: false.
gotcha addModuleOptions defaults to true, which sets modules: false for all presets. This may conflict with presets that already define modules options. ↓
fix Explicitly set addModuleOptions: false if your presets handle modules themselves.
gotcha addExternalHelpersPlugin defaults to true, which adds the external-helpers plugin. If not used, helpers may be duplicated. ↓
fix Set addExternalHelpersPlugin: false only if you are sure you don't need it.
Install
npm install babelrc-rollup yarn add babelrc-rollup pnpm add babelrc-rollup Imports
- default wrong
const babelrc = require('babelrc-rollup')correctimport babelrc from 'babelrc-rollup' - babelrc() wrong
babelrc({ path: './.babelrc' })correctbabelrc({ path: '.babelrc', addModuleOptions: true }) - babelrc with findRollupPresets wrong
babelrc({ findRollupPresets: true, addModuleOptions: true })correctbabelrc({ findRollupPresets: true })
Quickstart
// rollup.config.js
import babelrc from 'babelrc-rollup';
import babel from 'rollup-plugin-babel';
export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: 'esm'
},
plugins: [
babel(babelrc())
]
};