gulp-rollup-lightweight
raw JSON → 1.0.11 verified Mon Apr 27 auth: no javascript maintenance
A thin lightweight Gulp plugin that wraps Rollup's JavaScript API into a Readable Stream, compatible with Gulp 4.x and Rollup 1.x. Version 1.0.11 is the latest stable release (no recent maintenance). It differs from alternatives like gulp-rollup by being simpler and supporting custom Rollup instances. Suitable for building bundles with ES modules and CommonJS via plugins.
Common errors
error Error: Cannot find module 'rollup' ↓
cause Rollup is not installed or not provided in config.
fix
npm install rollup --save-dev OR pass custom rollup instance via options.rollup
error TypeError: rollup is not a function ↓
cause Importing a named export instead of default.
fix
Use const rollup = require('gulp-rollup-lightweight'); (no destructuring)
error Error: 'input' is required ↓
cause Missing 'input' option in the config object.
fix
Add input: './src/main.js' to the rollup() options.
Warnings
deprecated rollup-plugin-node-resolve and rollup-plugin-commonjs are deprecated; use @rollup/plugin-node-resolve and @rollup/plugin-commonjs instead. ↓
fix Replace with npm install @rollup/plugin-node-resolve @rollup/plugin-commonjs and update imports.
gotcha Stream will emit error if Rollup build fails; ensure proper error handling in Gulp pipeline. ↓
fix Use gulp-plumber or try-catch in the task function.
gotcha The plugin does not include vinyl-source-stream; you must install it separately to create virtual files. ↓
fix npm install --save-dev vinyl-source-stream
breaking Version 1.0.0 dropped support for Rollup <1.0 and Gulp <4. ↓
fix Upgrade to Rollup 1.x+ and Gulp 4.x+.
Install
npm install gulp-rollup-lightweight yarn add gulp-rollup-lightweight pnpm add gulp-rollup-lightweight Imports
- default wrong
import rollup from 'gulp-rollup-lightweight';correctconst rollup = require('gulp-rollup-lightweight'); - default
import rollup from 'gulp-rollup-lightweight'; - default wrong
const { rollup } = require('gulp-rollup-lightweight');correctconst rollup = require('gulp-rollup-lightweight').default;
Quickstart
const { dest } = require('gulp');
const rollup = require('gulp-rollup-lightweight');
const source = require('vinyl-source-stream');
function bundle() {
return rollup({
input: './src/main.js',
output: {
format: 'umd'
}
})
.pipe(source('app.js'))
.pipe(dest('./dist'));
}
exports.bundle = bundle;