Rollup

Rollup ES module bundler. Use for library bundling.

majiayu000 758d17b 2 files · 1.8 KB Updated 567 repo stars

File contents

Rollup

Rollup (v4) is the bundler of choice for libraries. It produces smaller, cleaner code than Webpack and pioneered Tree Shaking.

When to Use

  • NPM Packages: Building a library for others to use.
  • Flat Bundling: "Scope Hoisting" puts everything in one closure for performance.

Core Concepts

Tree Shaking

Rollup analyzes the import graph and excludes unused code statically.

Formats

Outputs esm, cjs, umd, iife.

Plugins

The ecosystem that Vite adopted.

Best Practices (2025)

Do:

  • Use pkg.exports: Configure package.json exports correctly for ESM/CJS dual publish.
  • Externalize dependencies: Don't bundle react into your library. Mark it as external.

Don't:

  • Don't use for Apps: Use Vite (which uses Rollup internally) for apps. Use Rollup directly for libs.

References

majiayu000/claude-skill-registry-data/tree/main/development/rollup-g1joshi-agent-skills commit 758d17bae6

Frequently asked questions

npx skillmds add majiayu000/rollup-2