Rollup was built specifically for ES modules when most bundlers were still wrestling with CommonJS. This head start means it actually understands your import
and export
statements instead of trying to retrofit support.
Tree-Shaking That Actually Works
The main reason you'd use Rollup is tree-shaking - it removes code you don't actually use. Webpack claims to do this too, but Rollup was designed around it from day one.
Here's where it gets good: import one function from a library and Rollup bundles just that function. With Webpack, you often get chunks of unused code because it can't figure out what you're actually using.
But tree-shaking breaks down when:
- Libraries export everything through a barrel file (
index.js
that re-exports 50 modules) - You're stuck with CommonJS modules - the plugin helps but it's not magic
- Some library decides to be "clever" with dynamic exports
- You import anything from lodash the wrong way (use lodash-es or individual imports like
import { debounce } from 'lodash-es'
)
Performance Reality Check
On my projects, Rollup builds finish while I'm getting coffee. Webpack builds finish while I'm making dinner. esbuild finishes before I can alt-tab, but you give up optimization.
- Build times: Fast enough that you won't get bored waiting, unlike Webpack where you have time for a full lunch break
- Bundle size: Actually smaller because tree-shaking works, not just claims to work
- Memory usage: Doesn't require 32GB of RAM like Webpack on enterprise codebases
The esbuild preset trades optimization for speed - your builds are instant but bundles are bigger.
When Rollup Makes Sense
Perfect for libraries: If you're publishing to npm, Rollup produces clean, optimized output that other tools can consume easily. Vue, React Router, and D3 all use it.
Good for apps prioritizing bundle size: If every KB matters and you can deal with the lack of dev server, Rollup will give you smaller bundles than alternatives.
Skip it if: You need hot module replacement, complex asset processing, or you're building a massive app with hundreds of entry points. Just use Vite instead - it uses Rollup for production builds anyway.
Real Problems You'll Hit
- No dev server: Watch mode rebuilds on file changes but without hot reload, you're constantly refreshing. I spent 2019 refreshing browsers like a caveman until Vite saved us
- CommonJS plugin hell: The plugin gives up on certain packages. react-dom is notorious for this. Spent 3 hours debugging why nothing was building - turns out Material-UI v4 has weird exports the plugin can't handle
- Plugin compatibility: Rollup 3.2.0 broke our CI pipeline because they changed how externals work. No warning, no migration guide, just broken builds on Monday morning
- Circular dependencies: Rollup doesn't just complain, it spams you with warnings until you fix them. Had a circular import in our Redux store that took down production because the bundle loaded modules in the wrong order