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-rollupVerified import paths — ran on the pinned version, not inferred.
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.
Replace `namespaceToStringTag` with the new `output.generatedCode.symbols` option to configure `Symbol.toStringTag` generation. Refer to the Rollup documentation for usage details.
Remove `dynamicImportFunction`. Migrate `inlineDynamicImports`, `manualChunks`, and `preserveModules` into the `output` object within your Rollup task options. Consult Rollup's v2 documentation for updated usage.
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.
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({...})]; }`).Ensure your Node.js environment is version 12 or higher to meet the current compatibility requirements of `grunt-rollup` and its dependencies.
Use `const plugin = require('@rollup/plugin-name').default;` to correctly access the plugin's main function from scoped packages within a CommonJS environment.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.
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.
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.