{"id":15443,"library":"grunt-rollup","title":"Grunt Rollup Plugin","description":"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.","status":"active","version":"12.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/chrisprice/grunt-rollup","tags":["javascript","gruntplugin","rollup","bundler","packager","build","tool"],"install":[{"cmd":"npm install grunt-rollup","lang":"bash","label":"npm"},{"cmd":"yarn add grunt-rollup","lang":"bash","label":"yarn"},{"cmd":"pnpm add grunt-rollup","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for running Grunt tasks.","package":"grunt","optional":false}],"imports":[{"note":"grunt-rollup is a Grunt plugin loaded via grunt.loadNpmTasks in your Gruntfile.js, not a direct JavaScript module for import or require.","wrong":"import rollup from 'grunt-rollup';","symbol":"grunt.loadNpmTasks","correct":"grunt.loadNpmTasks('grunt-rollup');"},{"note":"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.","wrong":"import babel from '@rollup/plugin-babel';","symbol":"babel","correct":"const babel = require('@rollup/plugin-babel').default;"},{"note":"For non-scoped or simpler Rollup plugins, a direct require() typically suffices. Remember to install any Rollup plugins separately via npm.","wrong":"import commonjs from '@rollup/plugin-commonjs';","symbol":"commonjs","correct":"const commonjs = require('@rollup/plugin-commonjs');"}],"quickstart":{"code":"const babel = require('@rollup/plugin-babel').default;\n\nmodule.exports = function(grunt) {\n  grunt.initConfig({\n    rollup: {\n      options: {\n        // Common Rollup output options, often recommended to be explicit\n        output: {\n          format: 'es', // or 'cjs', 'umd', 'iife'\n          sourcemap: true\n        },\n        // Use a function to return plugins for stateful plugins or multiple bundles\n        plugins: function() {\n          return [\n            babel({\n              babelHelpers: 'bundled',\n              exclude: './node_modules/**' // Exclude node_modules to speed up transpilation\n            })\n            // Add other Rollup plugins here, e.g., require('@rollup/plugin-node-resolve').default()\n          ];\n        }\n      },\n      // Define multiple targets/bundles\n      app: {\n        files: {\n          'dest/bundle.js': 'src/entry.js' // Bundle src/entry.js into dest/bundle.js\n        }\n      },\n      anotherApp: {\n        files: {\n          'dest/bundle2.js': 'src/entry2.js' // Bundle src/entry2.js into dest/bundle2.js\n        }\n      }\n    }\n  });\n\n  // Load the grunt-rollup plugin\n  grunt.loadNpmTasks('grunt-rollup');\n\n  // Register a default task to run rollup\n  grunt.registerTask('default', ['rollup']);\n};\n","lang":"javascript","description":"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."},"warnings":[{"fix":"Replace `namespaceToStringTag` with the new `output.generatedCode.symbols` option to configure `Symbol.toStringTag` generation. Refer to the Rollup documentation for usage details.","message":"The `namespaceToStringTag` output option has been removed in Rollup v2.71.1.","severity":"breaking","affected_versions":">=12.0.0"},{"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.","message":"The `dynamicImportFunction` option has been deprecated, and options like `inlineDynamicImports`, `manualChunks`, and `preserveModules` have been moved to the `output` configuration object.","severity":"breaking","affected_versions":">=11.3.0"},{"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.","message":"Version 11.0.0 updated the underlying Rollup dependency to v2.x. This introduced significant breaking changes within Rollup itself.","severity":"breaking","affected_versions":">=11.0.0"},{"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({...})]; }`).","message":"Some 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure your Node.js environment is version 12 or higher to meet the current compatibility requirements of `grunt-rollup` and its dependencies.","message":"The `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`).","severity":"gotcha","affected_versions":">=12.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use `const plugin = require('@rollup/plugin-name').default;` to correctly access the plugin's main function from scoped packages within a CommonJS environment.","cause":"Incorrectly importing a scoped Rollup plugin (like `@rollup/plugin-babel`) in a CommonJS Gruntfile, missing the `.default` property.","error":"TypeError: (0 , _pluginBabel.default) is not a function"},{"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.","cause":"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.","error":"Error: [!] RollupError: Could not resolve 'module-name' from 'path/to/file.js'"},{"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.","cause":"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.","error":"Warning: Task \"rollup\" failed. Use --force to continue."},{"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.","cause":"The `Gruntfile.js` is not correctly structured, or the `grunt-rollup` plugin (or Grunt itself) has not been properly initialized or loaded.","error":"ReferenceError: grunt is not defined"}],"ecosystem":"npm"}