Rollup

Rollup

The JavaScript module bundler optimized for libraries

Features

  • Best-in-class tree shaking and dead code elimination
  • Rich plugin ecosystem with standardized API
  • Multiple output formats (ESM, CJS, UMD, IIFE)
  • Code splitting and dynamic imports support

Pros

  • Produces the smallest, cleanest output bundles
  • Plugin API has become an industry standard (used by Vite)
  • Excellent for library authoring with multiple output targets

Cons

  • Slower than Rust/Go-based alternatives for large projects
  • Dev server requires additional tooling (or use Vite)
  • Configuration can be verbose for complex setups

Overview

Rollup is a JavaScript module bundler that pioneered ES module-based bundling and tree shaking. Created by Rich Harris (also the creator of Svelte), Rollup was designed with a focus on producing efficient, clean output by leveraging the static structure of ES modules.

Rollup’s tree shaking capabilities remain among the best in the ecosystem, making it the preferred choice for library authors who need to ship the smallest possible code. Its plugin API has become an industry standard, adopted by Vite and other tools.

While newer Rust-based bundlers are faster for large applications, Rollup remains the gold standard for library bundling and is the production bundler behind Vite.

When to Use

Choose Rollup for authoring JavaScript libraries where output quality and size matter most. For application development, use Vite (which uses Rollup under the hood) instead of configuring Rollup directly.

Getting Started

npm install --save-dev rollup
npx rollup src/index.js --file dist/bundle.js --format esm