Rollup is a JavaScript module bundler for ES modules
Next-generation ES module bundler
At a glance
- What is it?
- Rollup compiles small pieces of code into larger bundles using the standardized ES module format, and statically analyzes imports to tree-shake unused code for lighter output.
- Who is it for?
- Rollup is a JavaScript module bundler built around the standardized ES module format. It compiles small pieces of code into libraries and applications, supports output as CommonJS, AMD, UMD, or IIFE, and statically analyzes imports to tree-shake code you never use.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 28, 2026, and from our analysis. They are not legal advice.
Editorial analysis
A module bundler built on ES modules
Rollup is a module bundler for JavaScript that compiles small pieces of code into something larger and more complex, such as a library or an application. It uses the standardized ES module format for code instead of earlier idiosyncratic solutions such as CommonJS and AMD. ES modules let you combine the individual functions you need from your favorite libraries.
Rollup can optimize ES modules for faster native loading in modern browsers, or it can output a legacy module format so you can keep ES module workflows today. The tool is aimed at authors who want to publish reusable libraries as well as developers building applications, and it works from both a command line interface and a JavaScript API.
Installing Rollup and first commands
You install Rollup globally with npm install --global rollup, then run rollup --help to see the available options and parameters. The README points to starter project templates, rollup-starter-lib and rollup-starter-app, that demonstrate common configuration options, and to the user guide for detailed instructions.
A minimal build compiles an entry point such as main.js into a single bundle.js. For a browser target the README shows this command:
# compile to a <script> containing a self-executing function
rollup main.js --format iife --name "myBundle" --file bundle.jsThe --format iife flag wraps the output in a self-executing function suitable for a script tag, and --name sets the bundle name used by the IIFE.
Choosing an output module format
Rollup can emit several module formats from the same ES module source. For Node.js the README uses the CommonJS format, and for both browsers and Node.js it uses UMD, which requires a bundle name. Each format targets a different runtime, so the --format flag is the main switch.
# compile to a CommonJS module
rollup main.js --format cjs --file bundle.js# UMD format requires a bundle name
rollup main.js --format umd --name "myBundle" --file bundle.jsThe CommonJS build produces a module Node.js can require directly, while the UMD build works in browsers and Node.js alike. Picking the right format lets one source tree serve multiple consumers without rewriting the code.
Why Rollup uses ES modules
The README explains the motivation by noting that software is easier to build when you break a project into smaller pieces, since that removes unexpected interactions and reduces complexity. JavaScript historically lacked this as a core language feature, which changed when ES modules arrived and gave the language an import and export syntax for sharing code between scripts.
Most browsers and Node.js now support ES modules, but Node.js releases before 12.17 supported them only behind the --experimental-modules flag, and older browsers like Internet Explorer did not support them at all. Rollup lets you write code with ES modules and still run it where support is missing, by compiling to formats such as CommonJS, AMD, and IIFE. This lets you write future-proof code while keeping older runtimes working.
For library authors this matters because a dependency written in ES modules can be consumed natively by modern bundlers, while legacy users still get a working build. Rollup bridges that gap without asking the author to maintain two separate source trees, which keeps a single codebase useful across many years of tooling.
Tree shaking removes unused code
Beyond enabling ES modules, Rollup statically analyzes the code you import and excludes anything that is not actually used. The README shows the contrast with CommonJS, where the entire tool or library must be imported even if you need a single function.
// import the entire utils object with CommonJS
var utils = require('node:utils');
var query = 'Rollup';
// use the ajax method of the utils object
utils.ajax('https://api.example.com?search=' + query).then(handleResponse);With ES modules you import just the function you need, so Rollup includes the bare minimum and produces lighter, faster, and less complicated output. Because the approach relies on explicit import and export statements, it is more effective than running an automated minifier to find unused variables after compilation.
Interoperating with CommonJS and publishing
Rollup can import existing CommonJS modules through a plugin, which keeps you compatible with the large body of CommonJS packages. The CommonJS plugin approach means you do not have to wait for the ecosystem to migrate before using those packages in an ES module project. To publish your own ES modules, the README suggests compiling to UMD or CommonJS with Rollup and pointing to that compiled version with the main property in package.json.
If package.json also has a module field, ES-module-aware tools such as Rollup and webpack will import the ES module version directly. This dual approach means your library loads natively where possible and falls back to the compiled build elsewhere, without forcing every consumer to adopt ES modules. Rollup itself is published under the MIT license.
Editorial conclusion
Rollup is a JavaScript module bundler built around the standardized ES module format. It compiles small pieces of code into libraries and applications, supports output as CommonJS, AMD, UMD, or IIFE, and statically analyzes imports to tree-shake code you never use. The command line and JavaScript API both drive the tool, and starter templates make the first build straightforward. For library authors the dual main and module fields let one source serve every consumer, while the CommonJS plugin keeps older packages in reach. If you write ES modules and care about bundle size, Rollup is a direct fit.
Frequently asked questions
What is a rollup?
In this project, Rollup is a module bundler for JavaScript that compiles small pieces of code into larger bundles such as a library or an application. It uses the standardized ES module format and can tree-shake unused imports. It is not related to the dessert or any slang meaning of the word.
How do I install Rollup?
You install Rollup globally with the command npm install --global rollup, then run rollup --help to list options and parameters. From there you can build an entry point such as main.js into a bundle.js using the command line interface or the JavaScript API. Starter templates show common setups.
What output formats does Rollup support?
Rollup can output ES modules plus legacy formats including CommonJS, AMD, UMD, and IIFE. You choose the format with the --format flag, and UMD requires a bundle name through --name. This lets one ES module source serve browsers, Node.js, and older runtimes.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/rollup-rollup)