Registry / devops / grunt-rollup

grunt-rollup

JSON →
library12.0.0jsnpmunverified

grunt-rollup is a Grunt plugin that provides an interface to Rollup.js, a next-generation ES6 module bundler, within the Grunt build system. It enables developers to integrate Rollup's advanced tree-shaking and module bundling capabilities directly into their existing Grunt workflows. The package is currently stable at version 12.0.0, released recently with updates to Rollup v2.71.1 and Grunt v1.5.2, reflecting a cadence of updates to stay current with its core dependencies. Its primary function is to abstract the Rollup JavaScript API into Grunt tasks, allowing full configuration of Rollup options, sourcemap generation, and integration of Rollup plugins. This makes it a suitable choice for projects already heavily invested in Grunt that require modern JavaScript module bundling without migrating to a different task runner.

npm install grunt-rollup
INSTALL
IMPORT
SIG · GRUNT-ROLLUP
G
grunt-rollup
devopsjavascriptv12.0.0
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.

grunt.loadNpmTasks
grunt.loadNpmTasks('grunt-rollup');
import rollup from 'grunt-rollup';
grunt-rollup is a Grunt plugin loaded via grunt.loadNpmTasks in your Gruntfile.js, not a direct JavaScript module for import or require.
babel
const babel = require('@rollup/plugin-babel').default;
import babel from '@rollup/plugin-babel';
Gruntfile.js is typically CommonJS. Many scoped Rollup plugins like @rollup/plugin-babel export their main function as a .default property when required for CommonJS compatibility.
commonjs
const commonjs = require('@rollup/plugin-commonjs');
import commonjs from '@rollup/plugin-commonjs';
For non-scoped or simpler Rollup plugins, a direct require() typically suffices. Remember to install any Rollup plugins separately via npm.

This quickstart demonstrates how to configure 'grunt-rollup' in a Gruntfile.js, including setting up basic Rollup options, integrating the `@rollup/plugin-babel`, and correctly handling stateful plugins with a function for multiple output bundles.

const babel = require('@rollup/plugin-babel').default; module.exports = function(grunt) { grunt.initConfig({ rollup: { options: { // Common Rollup output options, often recommended to be explicit output: { format: 'es', // or 'cjs', 'umd', 'iife' sourcemap: true }, // Use a function to return plugins for stateful plugins or multiple bundles plugins: function() { return [ babel({ babelHelpers: 'bundled', exclude: './node_modules/**' // Exclude node_modules to speed up transpilation }) // Add other Rollup plugins here, e.g., require('@rollup/plugin-node-resolve').default() ]; } }, // Define multiple targets/bundles app: { files: { 'dest/bundle.js': 'src/entry.js' // Bundle src/entry.js into dest/bundle.js } }, anotherApp: { files: { 'dest/bundle2.js': 'src/entry2.js' // Bundle src/entry2.js into dest/bundle2.js } } } }); // Load the grunt-rollup plugin grunt.loadNpmTasks('grunt-rollup'); // Register a default task to run rollup grunt.registerTask('default', ['rollup']); };
Debug
Known issues
breakingThe `namespaceToStringTag` output option has been removed in Rollup v2.71.1.
fix
Replace `namespaceToStringTag` with the new `output.generatedCode.symbols` option to configure `Symbol.toStringTag` generation. Refer to the Rollup documentation for usage details.
affects: >=12.0.0
breakingThe `dynamicImportFunction` option has been deprecated, and options like `inlineDynamicImports`, `manualChunks`, and `preserveModules` have been moved to the `output` configuration object.
fix
Remove `dynamicImportFunction`. Migrate `inlineDynamicImports`, `manualChunks`, and `preserveModules` into the `output` object within your Rollup task options. Consult Rollup's v2 documentation for updated usage.
affects: >=11.3.0
breakingVersion 11.0.0 updated the underlying Rollup dependency to v2.x. This introduced significant breaking changes within Rollup itself.
fix
Carefully review the official Rollup v2 migration guide for any breaking changes in Rollup's core configuration, API, or plugin ecosystem that might affect your project's build process.
affects: >=11.0.0
gotchaSome Rollup plugins are stateful (e.g., keeping track of used Babel helpers) and can cause unexpected behavior when reused across multiple bundles in a single 'grunt-rollup' task.
fix
To ensure a fresh plugin instance for each bundle, pass a function that returns an array of plugins to the `options.plugins` property (e.g., `plugins: function() { return [babel({...})]; }`).
affects: >=0.1.0
gotchaThe `package.json` for `grunt-rollup` specifies a minimum Node.js version of `>=12`, which is higher than what older `README.md` versions might state (`>=8.6.0`).
fix
Ensure your Node.js environment is version 12 or higher to meet the current compatibility requirements of `grunt-rollup` and its dependencies.
affects: >=12.0.0
Errors
Common errors & fixes
TypeError: (0 , _pluginBabel.default) is not a function
Incorrectly importing a scoped Rollup plugin (like `@rollup/plugin-babel`) in a CommonJS Gruntfile, missing the `.default` property.
fix
Use `const plugin = require('@rollup/plugin-name').default;` to correctly access the plugin's main function from scoped packages within a CommonJS environment.
Error: [!] RollupError: Could not resolve 'module-name' from 'path/to/file.js'
Rollup cannot find an imported module, often because the module is not installed or the `@rollup/plugin-node-resolve` is missing from the plugins array.
fix
First, ensure all project dependencies are installed (`npm install`). Then, include `@rollup/plugin-node-resolve` in your `options.plugins` array within `Gruntfile.js` to enable Node.js style module resolution.
Warning: Task "rollup" failed. Use --force to continue.
A general Grunt task failure, typically indicating underlying configuration errors in the Rollup setup, such as invalid options, non-existent entry files, or issues with Rollup plugins.
fix
Run Grunt with verbose logging (`grunt rollup --verbose`) to reveal the detailed Rollup error messages, which will pinpoint the exact issue in your `Gruntfile.js` or Rollup configuration.
ReferenceError: grunt is not defined
The `Gruntfile.js` is not correctly structured, or the `grunt-rollup` plugin (or Grunt itself) has not been properly initialized or loaded.
fix
Ensure your `Gruntfile.js` adheres to the standard Grunt structure: `module.exports = function(grunt) { ... };` and that `grunt.loadNpmTasks('grunt-rollup');` is called within this function.
Upgrade
Version history
12.0.0latest on npm
Audit
Dependencies
gruntrequiredRequired peer dependency for running Grunt tasks.
Agent activity
2 hits · last 30 days
node
2
Resources