4 Changes That Break Your Build
Rollup 4 enforces strict ESM compliance, removing the legacy bundler behaviors that previously masked configuration errors. This section details the four specific breaking changes that will cause immediate build failures in your WordPress environment and provides the exact migration steps required to restore compatibility.
-

Native ESM config files are now mandatory
Rollup 4 drops support for .cjs and .mjs config files, requiring .mjs or .js with "type": "module" in package.json . This shift forces developers to rewrite configuration syntax, replacing module.exports with export default . Use the provided image to visualize the underlying ESM mechanics driving this change. Ensure your root package.json declares the module type before attempting any build, or face immediate parsing errors during initialization. -

CommonJS plugin support is completely removed
The legacy @rollup/plugin-commonjs wrapper is gone, breaking builds relying on Node.js-style libraries. You must now use @rollup/plugin-node-resolve alongside @rollup/plugin-commonjs replacement strategies or migrate dependencies to native ESM. This removal eliminates automatic interop, meaning any remaining CJS packages will cause unresolved export errors. Audit your node modules for hidden CJS dependencies that previously worked due to automatic transpilation. -

Strict module resolution replaces legacy fallbacks
Rollup 4 enforces strict module resolution, removing the forgiving fallbacks that previously masked missing dependencies or incorrect paths. If a module specifier does not resolve to a valid file, the build fails immediately rather than silently skipping or guessing. This change exposes hidden bugs in your import paths. Verify every relative and absolute path in your configuration to ensure they point to existing files, preventing abrupt build termination. -

RSPack compatibility changes build workflows
Integration with RSPack introduces significant workflow adjustments, as RSPack’s webpack-compatible API diverges from Rollup’s native ESM expectations. You may need to adjust plugin order or configuration objects to bridge the gap between the two bundlers. This change impacts how assets are processed and how tree-shaking is applied. Review your RSPack configuration carefully to ensure compatibility with Rollup 4’s stricter output requirements and plugin interfaces.
Rollup 4 breaks backward compatibility
Rollup 4 is not a minor patch; it is a major architectural shift that breaks backward compatibility with Rollup 3. If your project relies on CommonJS plugins or legacy configuration patterns, your build will fail immediately upon upgrading. This release forces a clean break from older JavaScript module systems to enforce native ES module syntax across the entire toolchain.
The most significant change is the removal of CommonJS plugin support. Plugins must now be written as ES modules. This means you cannot simply load a .cjs file in your rollup.config.js. Instead, your configuration file itself must be an ES module, typically by renaming it to rollup.config.mjs or adding "type": "module" to your package.json. This aligns Rollup with the broader JavaScript ecosystem's move toward native ESM, ensuring better compatibility with modern bundlers and tree-shaking mechanisms.
Stricter plugin APIs further tighten the ecosystem. Internal APIs that were previously exposed to plugins are now restricted, preventing accidental reliance on unstable internals. This forces plugin authors to adopt more robust, standard-compliant patterns. For projects with many custom or third-party plugins, this migration requires careful auditing. You will need to verify that each plugin supports ES modules and adheres to the new API constraints.
This shift is intentional. By enforcing native ESM, Rollup 4 reduces the complexity of its internal codebase and improves performance for modern JavaScript projects. It eliminates the overhead of transpiling CommonJS modules at build time, resulting in faster builds and smaller bundle sizes. While the migration path requires effort, the long-term benefits for 2026 projects include better compatibility, improved tooling, and a more maintainable codebase.
Rollup 4 migration: what to check next
Migrating from Rollup 3 to 4 often triggers confusion about costs, tool comparisons, and terminology. Below are direct answers to the most common technical questions developers face during this transition.
| Feature | Rollup 4 | Webpack |
|---|---|---|
| Primary Use Case | Library & App Bundling | Complex Application Bundling |
| Tree Shaking | Native (ESM) | Requires Optimization |
| Configuration | Minimal | Extensive |


No comments yet. Be the first to share your thoughts!