Rollup is a JavaScript module bundler that pioneered tree-shaking and ES module output. Created by Rich Harris, it influenced how all modern bundlers optimize code.
Key Innovation
Rollup introduced tree-shaking to JavaScript:
- Dead code elimination: Remove unused exports
- ES module output: Native browser module format
- Flat bundles: Hoist code to single scope
- Smaller output: Significant size reductions
Tree-Shaking
Tree-shaking eliminates code that isn’t actually used:
// library.js
export function used() {}
export function unused() {}
// app.js
import { used } from './library.js';
Rollup removes unused() from the final bundle.
Impact
Rollup’s innovations spread throughout the ecosystem:
- Webpack added tree-shaking support
- esbuild and other bundlers adopted the concept
- Library authors optimize for tree-shaking
- Vite uses Rollup for production builds
Use Cases
Rollup excels at:
- Building JavaScript libraries
- Producing optimized ES module output
- Creating multiple output formats from one source
- Applications where bundle size matters most