Modern Gulp plugin for Rollup 4.x - Bundle JavaScript modules with tree-shaking, multiple output formats (UMD, ESM, CJS, IIFE), and full Rollup API support. Actively maintained.
A powerful Gulp plugin for Rollup that allows you to use Rollup's module bundler before or after any gulp plugins with full Rollup API support.
- ✅ Supports the latest Rollup version (4.x)
- ✅ Multiple output formats (UMD, AMD, ES, CJS, IIFE, System)
- ✅ Works with Gulp 4.x
- ✅ Source map support
- ✅ Cache support for faster rebuilds
- ✅ Modern Node.js support (18+)
npm install --save-dev gulp-rollup-2Use between gulp.src() and gulp.dest():
const { src, dest } = require('gulp');
const gru2 = require('gulp-rollup-2');
function bundle() {
return src('./src/**/*.js')
.pipe(
gru2.rollup({
input: 'src/app.js',
external: ['window'],
plugins: [plugin1(), plugin2()],
cache: true,
output: [
{
file: 'example.js',
name: 'example',
format: 'umd',
globals: { window: 'window' },
},
{
file: 'example.esm.bundle.js',
format: 'es',
globals: { window: 'window' },
},
],
})
)
.pipe(dest('./dist'));
}
exports.bundle = bundle;When gulp-rollup-2 comes first in the pipeline:
const { dest } = require('gulp');
const gru2 = require('gulp-rollup-2');
const sourcemaps = require('gulp-sourcemaps');
async function bundle() {
return (
await gru2.src({
input: 'src/app.js',
plugins: [plugin1()],
output: {
file: 'bundle.js',
format: 'umd',
name: 'MyBundle',
},
})
)
.pipe(sourcemaps.write('.'))
.pipe(dest('dist'));
}
exports.bundle = bundle;Use inside a gulp pipeline. The options parameter accepts:
- A single Rollup configuration object
- An array of Rollup configuration objects
- A format string (e.g.,
'umd','es')
Use as the first step in a gulp pipeline. Requires the input option to be specified.
Supports all standard Rollup options:
input- Entry point fileexternal- External module IDsplugins- Array of Rollup pluginscache- Enable caching for faster rebuildsoutput- Output configuration (can be an array for multiple outputs)file- Output file nameformat- Module format (umd, amd, es, cjs, iife, system)name- Global variable name (for UMD/IIFE)globals- External module mappings
See Rollup documentation for complete options.
You can generate multiple bundles from a single source:
gru2.rollup({
input: 'src/main.js',
output: [
{ file: 'dist/bundle.umd.js', format: 'umd', name: 'MyLib' },
{ file: 'dist/bundle.esm.js', format: 'es' },
{ file: 'dist/bundle.cjs.js', format: 'cjs' },
],
});Source maps from previous gulp plugins (like gulp-sourcemaps) will be preserved unless you enable Rollup's sourcemap option:
gru2.rollup({
input: 'src/app.js',
output: {
file: 'bundle.js',
format: 'umd',
sourcemap: true, // This will override any existing source maps
},
});- Node.js >= 18.0.0
- Gulp >= 4.0.0
- Rollup >= 4.0.0
- 🚀 Updated config files to latest standards
- 🚀 Improved development workflow
- 🚀 Better code quality tools
- 🚀 Updated SEO-friendly package description
- Dependency updates
- 🚀 Updated to Rollup 4.x
- 🚀 Node.js 18+ support
- 🚀 Modernized dependencies
- 🚀 Added GitHub Actions CI
- 🚀 Improved code quality with Prettier & ESLint
- Previous stable release
Contributions are welcome! Please feel free to submit a Pull Request.
When you encounter a problem, please open an issue. I would be glad to help you find a solution.
Orçun Saltık
- GitHub: @orcunsaltik
- Email: [email protected]
MIT © Orçun Saltık