rollup
Rollup is a JavaScript module bundler that compiles small pieces of code into larger, more complex bundles optimized for distribution. Rollup pioneered tree sha…
Installation
npm install -D rollup
yarn add -D rollup
pnpm add -D rollup
Import
// rollup.config.js
export default { input: 'src/index.js' };Quick Example
// rollup.config.js
export default {
input: 'src/index.js',
output: [
{ file: 'dist/bundle.cjs', format: 'cjs' },
{ file: 'dist/bundle.mjs', format: 'es' },
],
};About rollup
Rollup is a JavaScript module bundler that compiles small pieces of code into larger, more complex bundles optimized for distribution. Rollup pioneered tree shaking — the process of eliminating unused code by analyzing ES module import/export statements to determine which exports are actually consumed. This produces smaller bundles than tools that cannot perform dead code elimination at the module level. Rollup is particularly well-suited for building JavaScript libraries because it generates clean, readable output in multiple formats (ESM, CommonJS, UMD, IIFE) from a single source, and its tree-shaking ensures consumers only include the code they actually use. Rollup uses a plugin architecture for extending functionality including code transformation (Babel, TypeScript), module resolution (node_modules), CommonJS interop, JSON handling, and asset management. Vite uses Rollup as its production bundler, exposing a compatible plugin interface. While Rollup excels at library bundling, its lack of built-in code splitting for applications and slower development server experience compared to Vite mean it is less commonly used directly for application development. Rollup's output quality and tree-shaking capabilities remain best-in-class.
Quick Facts
| Package | rollup |
| Category | Build Tool |
| Weekly Downloads | 12M+ |
| License | MIT |
| Install | npm install -D rollup |
Related Packages
Vite is a next-generation frontend build tool created by Evan You (creator of Vue.js) that provides …
Webpack is a powerful and highly configurable static module bundler for modern JavaScript applicatio…
esbuild is an extremely fast JavaScript and TypeScript bundler and minifier written in Go that is 10…
tsup is a zero-config TypeScript bundler powered by esbuild, designed specifically for building Type…
Microbundle is a zero-configuration bundler for tiny JavaScript modules, designed to produce optimiz…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.