gulp-rollup-2

raw JSON →
2.1.0 verified Mon Apr 27 auth: no javascript

gulp-rollup-2 v2.1.0 is a modern Gulp plugin for Rollup 3.x/4.x, providing native Rollup API integration in Gulp pipelines. It features production-grade caching with object-hash for stable incremental builds, automatic duplicate output detection, memory-safe bundle cleanup, and intelligent sourcemap handling. Supports multiple output formats (ES, CJS, UMD, IIFE, AMD, System) and dual modes (pipe or standalone src). Actively maintained with monthly releases.

error Error: Output files must be unique. Duplicate outputs detected: ...
cause Multiple rollup output configurations target the same `file` path.
fix
Ensure each output object has a unique file value, e.g., 'bundle.esm.js' and 'bundle.cjs.js'.
error TypeError: rollup2.rollup is not a function
cause Incorrect import - trying to call default export as function or using wrong named import.
fix
Use const { rollup } = require('gulp-rollup-2'); (destructured named export).
error Error: Cannot find module 'rollup'
cause Rollup is not installed as a peer dependency.
fix
Run npm install --save-dev rollup@^4.0.0.
breaking Node.js >= 18.0.0 required. Older versions (16.x or below) are not supported.
fix Upgrade Node.js to LTS version 18+.
breaking Rollup >=4.0.0 required. Rollup 3.x may work but is untested.
fix Install rollup@^4.0.0.
gotcha Output files must be unique; duplicate outputs throw an error.
fix Ensure each output has a distinct `file` path.
gotcha When using watch mode, caching may not re-trigger if only transitive dependencies change; consider disabling cache for dynamic plugins.
fix Set `cache: false` in options if plugins have side effects.
deprecated gulp-rollup and rollup-stream are legacy packages; migrate to gulp-rollup-2.
fix Replace with gulp-rollup-2 and update API calls.
npm install gulp-rollup-2
yarn add gulp-rollup-2
pnpm add gulp-rollup-2

Basic Gulp task using gulp-rollup-2 to bundle src/index.js with Rollup plugins and output IIFE with sourcemap.

const gulp = require('gulp');
const rollup2 = require('gulp-rollup-2');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');

gulp.task('bundle', () =>
  gulp
    .src('src/index.js')
    .pipe(
      rollup2.rollup({
        input: 'src/index.js',
        plugins: [resolve(), commonjs()],
        output: {
          file: 'bundle.js',
          format: 'iife',
          name: 'App',
          sourcemap: true,
        },
      })
    )
    .pipe(gulp.dest('dist'))
);