broccoli-rollup
raw JSON → 5.0.0 verified Mon Apr 27 auth: no javascript
A Broccoli plugin that bundles input files using Rollup.js. This is a stable v5 release (2022) with TypeScript definitions. It supports basic bundling, code splitting, and multiple outputs. Key differentiators: it preserves Broccoli's immutable input model by using a cache directory and symlinks node_modules, ensuring compatibility with Rollup's CLI features. Alternatives like ember-auto-import are Ember-specific; this is a generic Broccoli plugin.
Common errors
error Cannot find module 'broccoli-rollup' ↓
cause Package not installed or wrong import style.
fix
Install: npm install --save-dev broccoli-rollup / Use ESM import, not require().
error Error: rollup input must be relative to inputPath ↓
cause Providing an absolute path for rollup.input instead of a relative one.
fix
Use a path relative to the broccoli input directory (e.g., 'index.js').
error TypeError: (0 , ...) is not a function ↓
cause Using require() on an ESM-only package.
fix
Switch to import syntax or downgrade to v4.x.
Warnings
breaking Dropped support for Node < 12 in v5. ↓
fix Upgrade Node to >=12 or stay on v4.x (but v4 is unmaintained).
breaking v5 is ESM-only; CJS require() will throw. ↓
fix Use import syntax or downgrade to v4.x if CJS is required.
gotcha nodeModulesPath defaults to process.cwd() but is overridden by an internal symlink. ↓
fix Set nodeModulesPath explicitly if your node_modules is not at cwd.
deprecated The 'rollup' plugin wrapper configuration cannot use rollup's onwrite hook due to Broccoli's immutable input. ↓
fix Avoid onwrite; use broccoli output directly instead.
Install
npm install broccoli-rollup yarn add broccoli-rollup pnpm add broccoli-rollup Imports
- default wrong
const rollup = require('broccoli-rollup');correctimport rollup from 'broccoli-rollup'; - RollupOptions
import type { RollupOptions } from 'rollup'; - PluginOptions
import type { PluginOptions } from 'broccoli-rollup';
Quickstart
import rollup from 'broccoli-rollup';
export default () =>
rollup('lib', {
rollup: {
input: 'index.js',
output: {
file: 'bundle.js',
format: 'es',
},
},
});