100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Web

Rollup

Created by Rich Harris

AdvancedTool10.1K learners

Rollup is a JavaScript module bundler that combines many small modules into a single, optimized file, particularly known for producing efficient, tree-shaken bundles well suited to publishing libraries.

Definition

Rollup is a JavaScript module bundler that combines many small modules into a single, optimized file, particularly known for producing efficient, tree-shaken bundles well suited to publishing libraries.

Overview

Rollup was one of the first bundlers to popularize efficient tree-shaking — statically analyzing ES module `import`/`export` statements to detect and remove code that's never used, producing smaller output bundles than bundlers relying on less precise dead-code elimination. This made it a favorite for building and publishing JavaScript libraries, where minimizing bundle size for consumers matters a great deal. Compared to application-focused bundlers, Rollup's configuration model centers on a single entry (or a few entries) and a specific output format — ES modules, CommonJS, UMD, or IIFE — making it well suited to producing a clean package for npm publication rather than the more complex multi-entry, code-split output typical of large single-page applications. Rollup's design directly influenced other tools: Vite (web) uses Rollup itself for its production build step, and Rollup's plugin interface is largely compatible with Vite plugins, letting the same plugin ecosystem serve both tools. It's frequently discussed alongside other modern build tools like esbuild and Parcel, each optimizing for different trade-offs between configurability, speed, and output quality.

Key Features

  • Static analysis-based tree-shaking for minimal, dead-code-free bundles
  • Support for multiple output formats: ES modules, CommonJS, UMD, and IIFE
  • Plugin architecture that Vite also builds on and shares compatibility with
  • Well suited to bundling libraries and packages for npm publication
  • Code-splitting support for more complex multi-entry builds
  • Clear, predictable output favored for auditing bundle contents

Use Cases

Bundling and publishing JavaScript or TypeScript libraries to npm
Production build step inside Vite-powered applications
Projects prioritizing minimal, tree-shaken bundle output over bundler speed alone
Building UMD or IIFE bundles for direct browser script-tag consumption
Building browser-ready UMD or IIFE bundles for CDN or script-tag distribution

Frequently Asked Questions