gulp-rollup-each
raw JSON → 4.0.1 verified Mon Apr 27 auth: no javascript
Gulp plugin for Rollup that processes multiple input files individually, each with its own Rollup bundle. Current stable version is 4.0.1 (Rollup v2, released 2021). Release cadence is low; the plugin has been stable with occasional updates for Rollup major versions. Key differentiator: unlike other gulp-rollup plugins that combine all files into a single bundle, this plugin preserves the file-per-bundle pattern useful for static sites or multi-page apps. Supports Rollup cache, external modules, and custom rollup instance.
Common errors
error TypeError: rollupEach is not a function ↓
cause Importing incorrectly (e.g., destructuring a named export).
fix
Use
import rollupEach from 'gulp-rollup-each' or const rollupEach = require('gulp-rollup-each'). error Error: The `input` option cannot be specified as gulp-rollup-each option. ↓
cause Passing `input` in inputOptions.
fix
Remove
input from inputOptions; the input comes from gulp.src(). error Error: Rollup's `cache` option must be an object or boolean, but got something else. ↓
cause Using deprecated `isCache` option or malformed cache object.
fix
Use Rollup's
cache property: cache: true or a cache object. Remove isCache. Warnings
breaking v3.0.0 dropped Rollup 0.x support, only Rollup 1.0.0+. v4.0.0 dropped Rollup 1.x, only Rollup 2.x. ↓
fix Update Rollup to v1.x for v3.x, or v2.x for v4.x.
deprecated The `isCache` option is deprecated; Rollup cache is now managed internally. Use Rollup's cache option instead. ↓
fix Remove `isCache` and configure cache via Rollup's inputOptions.cache.
gotcha The `input` option is ignored because it is set automatically from gulp.src() file paths. ↓
fix Do not specify `input` in inputOptions; use gulp.src() to define entry files.
gotcha If you omit the second argument, the `output` property inside the first argument is used as outputOptions. This can be confusing when using a function for options. ↓
fix Always pass both arguments or use a function for the second argument to avoid ambiguity.
Install
npm install gulp-rollup-each yarn add gulp-rollup-each pnpm add gulp-rollup-each Imports
- default wrong
const { rollupEach } = require('gulp-rollup-each')correctimport rollupEach from 'gulp-rollup-each' - default wrong
const { rollupEach } = require('gulp-rollup-each')correctconst rollupEach = require('gulp-rollup-each') - default wrong
import { rollupEach } from 'gulp-rollup-each'correctimport rollupEach from 'gulp-rollup-each'
Quickstart
const gulp = require('gulp');
const rollupEach = require('gulp-rollup-each');
function scripts() {
return gulp
.src(['src/**/*.js', '!src/**/_*'])
.pipe(rollupEach({ output: { format: 'iife' } }))
.pipe(gulp.dest('dist'));
}
exports.default = scripts;