Gulp Plugin for Rollup ES6 Bundler

5.0.3 · active · verified Wed Apr 22

gulp-best-rollup-2 is a Gulp plugin designed for integrating the Rollup ES6 module bundler into a Gulp build pipeline. As a fork rewritten for Rollup v2.X and modern ES6, it provides a deeper integration than its predecessors and alternatives like `gulp-rollup`. The current stable version is 5.0.3, with maintenance releases occurring as needed for compatibility or bug fixes. Its key differentiator lies in how it handles file paths from `gulp.src()` directly within Rollup, allowing other Gulp plugins to operate effectively in the pipeline before or after the bundling step. This approach deviates from Rollup's typical file-reading mechanism, enabling greater flexibility in complex Gulp workflows by treating Rollup primarily as an in-memory transformation step, rather than a file handler.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates bundling an ES6 library with Rollup and Babel, applying sourcemaps, and outputting the CJS bundle to a 'dist' directory.

var gulp = require('gulp')
var sourcemaps = require('gulp-sourcemaps')
var rollup = require('gulp-better-rollup')
var babel = require('rollup-plugin-babel')

gulp.task('lib-build', () => {
  gulp.src('lib/index.js')
    .pipe(sourcemaps.init())
    .pipe(rollup({
      // There is no `input` option as rollup integrates into the gulp pipeline
      plugins: [babel({ babelHelpers: 'bundled' })] // Note: babelHelpers option often needed for babel plugin
    }, {
      // Rollups `sourcemap` option is unsupported. Use `gulp-sourcemaps` plugin instead
      format: 'cjs'
    }))
    // inlining the sourcemap into the exported .js file
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('dist'))
})

view raw JSON →