Building with Rollup?

Rollup bundle wrong or plugins misordered? We ship it properly.

Rollup is the bundler of choice for libraries because it produces tiny ES modules and treats tree-shaking as a first-class job, not an afterthought. It also assumes every plugin author got the order right, which is rarely true the first time. We work through the input options, the plugin pipeline and the output graph until the build is reproducible and the published package is actually small.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

rollup-build.log

still broken

What it is

Rollup at a glance

Rollup is a JavaScript module bundler written by Rich Harris, first released in 2015. It takes small pieces of code written as ES modules and assembles them into a single file or a set of chunks, with aggressive tree-shaking that strips anything the output does not actually use. The tool is open source under the MIT license.

The ecosystem is built around plugins. Official plugins under the @rollup scope cover Node resolution, CommonJS interop, JSON, Babel, TypeScript, Terser and virtual modules, and a long tail of community plugins handles Vue, Svelte, CSS, images and more. Rollup also serves as the production bundler inside Vite, which means fixing Rollup problems often fixes Vite builds too.

Type
JavaScript module bundler
First released
2015
License
MIT, open source
Maintained by
Lukas Taegert-Atkinson and contributors, originally Rich Harris
Typically used for
Publishing JavaScript and TypeScript libraries, tree-shaken application bundles, Vite production builds

The honest version

Rollup pros and cons

No technology is all upside. This is where Rollup earns its place and where it tends to cause trouble.

Where Rollup is strong

  • Best-in-class tree-shakingRollup was designed around ES modules from day one, so dead-code removal is deeper than bundlers that bolted it on later. Published packages come out meaningfully smaller.
  • Clean library outputMultiple output formats, ESM and CJS side by side, and well-formed module graphs make it the obvious choice for packages intended to be consumed by other builds.
  • A sharp plugin APIHooks are well documented, consistently named, and give authors precise control over resolution, transformation and chunking without monkey-patching the pipeline.
  • Powers Vite in productionIf you use Vite, you already use Rollup. Skills and fixes carry straight from one to the other, which is a quiet multiplier for any team.
  • Strong sourcemap disciplinePlugin output is checked for sourcemap continuity and warnings fire when a transform breaks the chain, so debuggers keep working through the pipeline.
  • Deterministic outputGiven the same input and plugin order, Rollup produces the same chunks. That matters for diffing releases, auditing a bundle, and reproducing a build on CI weeks later.

Where Rollup bites

  • Plugin ordering is a trapA plugin that should run before @rollup/plugin-commonjs and ends up after it will produce output that looks right and fails at runtime. The failure modes are rarely obvious from the log.
  • CommonJS interop is the usual sore pointMixing CJS packages into an ESM bundle through @rollup/plugin-commonjs can require per-package overrides, namedExports hints, and sometimes a patched fork of a dependency.
  • Not optimized for very large app graphsRollup will build an application, but on huge repos with thousands of modules the build time trails esbuild and SWC-based tools, and incremental builds are not its strength.
  • Error messages can be crypticA failed resolution in a nested plugin often surfaces as a terse warning without a stack trace, which sends you hunting through the config rather than the code.
  • Config can balloon quicklyA library that ships ESM, CJS, types and minified bundles ends up with a multi-entry rollup.config.js, conditional plugin arrays, and comments explaining why each line matters.
  • Watch mode is adequate, not fastFor library work it is fine. For an app dev loop, people rightly reach for Vite or esbuild instead and leave Rollup for the production pass.

Sound familiar?

Common Rollup problems we fix

The Rollup problems that bring people to us, and what you have once each one is fixed.

Could not resolve './utils'

The bundle cannot resolve an import

A missing file extension that Node tolerates but the resolver does not, a TypeScript path alias that was never wired into the plugin, or a package that has no exports map and no main field.

Imports resolving across the graph

'default' is not exported by lodash

CommonJS and ESM interop is broken

A CJS dependency being imported as a default export when it only has named ones, or the commonjs plugin missing a namedExports hint for a stubborn package.

Interop clean, named and default imports honest

Circular dependency a.js -> b.js -> a.js

Circular imports warn and silently break

Modules that reach into each other during initialization, leaving one side with undefined bindings and a runtime error well after the build looked fine.

Cycles broken, initialization deterministic

Unexpected token

A file type is not recognised

A .vue, .svelte, .css or JSON file reaching the bundler without the matching plugin, or a TypeScript file being handed to the default parser because the plugin order put it last.

Every file type has a plugin

"name" option is required for IIFE and UMD

The library output refuses to build

A UMD or IIFE target without a global name, or an output.exports mode mismatch between the entry's export shape and what the format expects.

Library builds across every format

Generated an empty chunk "vendor"

Code splitting produces empty chunks

A manualChunks function that groups by module id without accounting for dynamic imports, leaving a configured chunk with nothing inside it.

Chunking matches real import patterns

ReferenceError: process is not defined

The bundle leaks Node globals into the browser

A dependency that references process.env, a missing @rollup/plugin-replace step, or an inject plugin that was reordered out of its effective position.

Environment injected, no runtime surprises

Sourcemap is likely to be incorrect

Sourcemaps drift from the source

A transform plugin that returns new code without returning a map, which forces Rollup to guess for everything downstream in the pipeline.

Sourcemaps clean, debugger lands on the right line

What we do

Rollup help, from one broken build to a published package

Reach out for one failing Rollup error, or let us own the whole pipeline.

Rescue
A build that errors, a package that ships broken, or a tree-shaking regression no one can trace. We make it green before we draft the writeup.
Library publishing
Dual ESM and CJS outputs, correct exports fields, minified browser bundles, and declaration files that resolve for consumers rather than just for you.
Plugin order and config review
The pipeline rewritten so each plugin sees the input it was designed for, with a comment explaining why the order holds.
Bundle size work
Tracing where bytes come from, splitting dynamic imports sensibly, and killing dependencies that shipped half the lodash namespace without needing to.
Vite builds
When a Vite production build fails and the dev server is fine, the answer is usually inside Rollup. We fix it at that layer.
Managed Tech
Build upkeep, dependency bumps, release pipeline watching, and an engineer to call when a Rollup major version changes something the config relied on.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Rollup alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Rollup questions

Something else? Call+1 737 727 7327

Should we use Rollup or Webpack for our library?

For a library, Rollup almost always. The output is smaller, the module graph is cleaner, and consumers get an ESM bundle that their own tree-shaker can further reduce. Webpack earns its keep in applications with heavy code-splitting and a mature plugin ecosystem around framework integrations, not in packages intended to be imported by other builds.

Why are my Rollup builds not tree-shaking?

The common causes are dependencies that ship CommonJS, side effects declared in package.json that the bundler respects, re-exports through a barrel file that hide the shape of the module, and plugins that transform code without preserving ES module semantics. We look at each of those in order and fix whichever is actually in the way.

How do we fix the 'default is not exported' warning?

The dependency only has named exports; the import is asking for a default one. Either switch to a named import, let @rollup/plugin-commonjs synthesize a default through its defaultIsModuleExports option, or add an explicit namedExports hint for that package so the plugin knows what it is dealing with.

Can Rollup replace Webpack for applications?

Sometimes. Small to medium apps bundle cleanly on Rollup, especially through Vite. Large applications with many dynamic chunks, framework-specific loaders and intricate code-splitting rules will land on Webpack, Rspack or Turbopack sooner or later.

How do we keep Rollup and its plugins in sync?

Pin Rollup, pin the @rollup/* plugins, and upgrade them together on a schedule rather than one at a time. Plugin hooks move in lockstep with Rollup majors, and a mismatched pair often shows up as a cryptic resolution warning rather than a clean error.

How much does Rollup help cost?

Estimates cost nothing. Share the config, the error log and the package.json, and a price lands in your inbox before any work is scheduled.

Free estimate

Rollup giving you trouble?

Paste the config and the error. A human reads it, writes back with a quote, and nothing starts until you agree the price.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.