rollup-plugin-simple-babel
raw JSON → 1.0.6 verified Sat Apr 25 auth: no javascript maintenance
A simple Rollup plugin that wraps Babel to allow seamless transpilation during bundling. Version 1.0.6 (latest as of early 2019) is stable but low maintenance. It passes all Babel options through via the plugin invocation. Unlike @rollup/plugin-babel, it does not automatically select files or require Babel configuration; it transforms all JavaScript files. Recommended only for trivial setups; most projects should use @rollup/plugin-babel for better integration, performance, and automatic detection of Babel configs.
Common errors
error TypeError: Cannot read property 'transform' of undefined ↓
cause @babel/core is not installed or not properly resolved
fix
Run: npm install @babel/core --save-dev
error Error: Cannot find module '@babel/preset-env' ↓
cause Babel preset not installed
fix
Run: npm install @babel/preset-env --save-dev
error TypeError: babel is not a function ↓
cause Using named import or wrong import style
fix
Use default import: import babel from 'rollup-plugin-simple-babel'
Warnings
gotcha By default, this plugin transforms all files; no 'include' or 'exclude' filtering. ↓
fix Use @rollup/plugin-babel which supports filtering and is actively maintained.
deprecated Package is no longer actively maintained; use @rollup/plugin-babel instead. ↓
fix Migrate to @rollup/plugin-babel: npm install @rollup/plugin-babel --save-dev
breaking Requires Babel 7+; does not work with Babel 6. ↓
fix Ensure @babel/core and Babel presets/plugins are installed as devDependencies.
gotcha Does not read Babel configuration from .babelrc or babel.config.js automatically; you must pass options via plugin. ↓
fix Duplicate Babel options in rollup.config.js or use @rollup/plugin-babel which respects babel config files.
gotcha Package exports a single default function; named import (import { babel }) is undefined. ↓
fix Use default import: import babel from 'rollup-plugin-simple-babel'
Install
npm install rollup-plugin-simple-babel yarn add rollup-plugin-simple-babel pnpm add rollup-plugin-simple-babel Imports
- babel wrong
import { babel } from 'rollup-plugin-simple-babel'correctimport babel from 'rollup-plugin-simple-babel' - babel() wrong
plugins: [babel({...})] without calling as functioncorrectplugins: [babel()] - babel({presets: [...]}) wrong
plugins: [babel({presets: ['env']})]correctplugins: [babel({ presets: ['@babel/preset-env'] })]
Quickstart
// rollup.config.js
import babel from 'rollup-plugin-simple-babel';
import resolve from '@rollup/plugin-node-resolve';
export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
plugins: [
resolve(),
babel({
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime']
})
]
};