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.
npm install gulp-best-rollup-2Verified import paths — ran on the pinned version, not inferred.
Demonstrates bundling an ES6 library with Rollup and Babel, applying sourcemaps, and outputting the CJS bundle to a 'dist' directory.
Ensure `gulp-better-rollup` is placed early in the pipeline if other plugins' transformations are not meant to be superseded, or use plugins that don't perform source transformations (e.g., `gulp-sourcemaps`) before it.
Specify input files using `gulp.src()` instead of Rollup's `input` option. The plugin will automatically use the file paths from the Gulp stream.
Remove any `sourcemap: true` or similar options from Rollup's `outputOptions`. Instead, integrate `gulp-sourcemaps` into your Gulp pipeline before and after `gulp-better-rollup`.
If `.mjs` is critical, consider inlining sourcemaps (`sourcemaps.write()`) or creating external sourcemaps with a different file extension/naming convention. Check `gulp-sourcemaps` documentation for potential updates or workarounds for `.mjs`.
When using `gulp.dest()`, specify a target directory to allow Rollup's `output.file` to name the bundled output. Alternatively, use `gulp-rename` after `gulp-better-rollup` for precise output filename control.
Run `npm install rollup --save-dev` in your project directory.
Remove the `input` option from the first argument (Rollup `inputOptions`) passed to the `rollup()` plugin function.
Ensure `gulp-sourcemaps` is installed (`npm install gulp-sourcemaps --save-dev`) and correctly imported (`const sourcemaps = require('gulp-sourcemaps')`).