Registry / devops / gulp-best-rollup-2

gulp-best-rollup-2

JSON →
library5.0.3jsnpmunverified

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-2
INSTALL
IMPORT
SIG · GULP-BEST-ROLLUP-2
G
gulp-best-rollup-2
devopsjavascriptv5.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rollup
const rollup = require('gulp-better-rollup')
import { rollup } from 'gulp-better-rollup'
The plugin exports a default function. While Gulpfiles typically use CommonJS `require`, if using ESM Gulpfiles, `import rollup from 'gulp-better-rollup'` would be the equivalent correct import.
gulp
const gulp = require('gulp')
Standard import for the Gulp core library used to define tasks and pipelines.
babel
const babel = require('rollup-plugin-babel')
This demonstrates importing a common Rollup plugin (like `@rollup/plugin-babel`). Ensure all Rollup plugins are installed separately and imported similarly for inclusion in the `plugins` array.

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')) })
Debug
Known issues
gotchaTransformations from Gulp plugins executed *before* `gulp-better-rollup` in the pipeline will be lost. The plugin operates on file paths provided by `gulp.src()` directly, not on in-memory buffers transformed by previous plugins.
fix
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.
affects: *
gotchaThe Rollup `input` option (e.g., `input: 'src/main.js'`) is explicitly unsupported and will be ignored or cause errors.
fix
Specify input files using `gulp.src()` instead of Rollup's `input` option. The plugin will automatically use the file paths from the Gulp stream.
affects: *
gotchaRollup's native `output.sourcemap` option is unsupported. Sourcemap generation is delegated entirely to `gulp-sourcemaps`.
fix
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`.
affects: *
gotchaWhen using `gulp-sourcemaps` with `.mjs` files, the sourcemap linking comment (`//# sourceMappingURL=`) may not be inserted, rendering external sourcemaps ineffective.
fix
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`.
affects: *
gotchaThe Rollup `output.file` argument can only influence the filename if `gulp.dest()` specifies a directory. If `gulp.dest()` specifies a full file path, Rollup's `output.file` is completely ignored.
fix
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.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'rollup'
`rollup` is a peer dependency of `gulp-better-rollup-2` and must be installed separately.
fix
Run `npm install rollup --save-dev` in your project directory.
Input option must be specified.
This error occurs if you are mistakenly passing an `input` option to the `rollup()` plugin call. `gulp-better-rollup-2` expects input to be handled by `gulp.src()`.
fix
Remove the `input` option from the first argument (Rollup `inputOptions`) passed to the `rollup()` plugin function.
TypeError: Cannot read properties of undefined (reading 'init')
This usually indicates `sourcemaps.init()` was called, but `gulp-sourcemaps` was not properly imported or installed.
fix
Ensure `gulp-sourcemaps` is installed (`npm install gulp-sourcemaps --save-dev`) and correctly imported (`const sourcemaps = require('gulp-sourcemaps')`).
Upgrade
Version history
5.0.3latest on npm
Audit
Dependencies
rolluprequiredCore bundler engine; required as a peer dependency for functionality.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-best-rollup-2 — npm install gulp-best-rollup-2 · libregistry