🔧
Build Tool12M+/wkMIT

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
npm install -D rollup
yarn
yarn add -D rollup
pnpm
pnpm add -D rollup

Import

ESM
// rollup.config.js
export default { input: 'src/index.js' };

Quick Example

usage
// 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

Packagerollup
CategoryBuild Tool
Weekly Downloads12M+
LicenseMIT
Installnpm install -D rollup

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.