Rolldown 1.4.0 was released on 2 December 2026. Rolldown is the Rust-based bundler from the Vite team, and this is a minor release with one headline feature: experimental support for import defer, the TC39 proposal for deferred module evaluation. It also contains three breaking changes in default behaviour that could surprise you during a routine dependency bump.
This tutorial explains what import defer does, shows a working setup (I built and ran every example with Rolldown 1.4.0 on Node.js 26.14.0), and covers what to check before you upgrade.
What is import defer?
A normal import loads and evaluates a module before your code runs. If that module is heavy (a charting library, a big locale table, a module with expensive top-level setup), you pay the cost at startup even if you never use it.
The Deferring Module Evaluation proposal adds a new import phase:
import defer * as heavy from './heavy.js';
The module is still loaded and linked, but its body only runs the first time you touch the namespace, for example heavy.value. Unlike dynamic import(), your code stays synchronous. You don’t need await or to restructure anything into async functions.
A dynamic form exists too: import.defer('./heavy.js') returns a promise for a deferred namespace.
Turn it on in Rolldown
Install or upgrade:
npm install -D [email protected]
Then enable the experimental flag. Note that a config using import syntax needs "type": "module" in package.json or a .mjs file name. Without it, Rolldown fails with “Cannot use import statement outside a module”.
// rolldown.config.js
import { defineConfig } from 'rolldown';
export default defineConfig({
input: 'src/main.js',
platform: 'node',
output: { dir: 'dist', format: 'esm' },
experimental: {
importDefer: true,
},
});
A runnable example
src/heavy.js has a visible side effect so we can see when it runs:
// src/heavy.js
console.log('heavy.js evaluated');
export const value = 42;
export function format(n) { return `#${n}`; }
src/main.js only uses it when a flag is passed:
// src/main.js
import defer * as heavy from './heavy.js';
console.log('start');
if (process.argv.includes('--use-heavy')) {
console.log(heavy.format(heavy.value));
}
console.log('done');
Build and run:
$ npx rolldown -c rolldown.config.js
✔ rolldown v1.4.0 Finished in 17.22 ms
$ node dist/main.js
start
done
$ node dist/main.js --use-heavy
start
heavy.js evaluated
#42
done
Without the flag, heavy.js never runs. With it, it runs exactly when the namespace is first accessed, after start.
What Rolldown generates
Rolldown wraps the deferred module in an initialiser and calls it at each access point. The relevant part of the output looked like this:
function init_heavy() {
return (init_heavy = __esmSync((() => {
console.log("heavy.js evaluated");
})))();
}
// src/main.js
console.log("start");
if (process.argv.includes("--use-heavy"))
console.log((init_heavy(true), format)((init_heavy(true), 42)));
console.log("done");
Because evaluation happens in the bundle, the deferred behaviour works in today’s runtimes even if they don’t support import defer natively.
What happens with the flag off
With importDefer: false (the default), Rolldown compiles import defer to a regular import and prints a clear warning:
src/main.js (1:0) [UNSUPPORTED_FEATURE] `import defer` is currently lowered to a
normal import. This changes execution timing because side effects run immediately
instead of when the deferred import is first used. Set `experimental.importDefer`
to `true` to keep the deferred evaluation.
Running that bundle printed heavy.js evaluated before start. That’s normal import timing. Watch for this if a library you depend on starts shipping import defer.
The dynamic form: import.defer()
// src/dyn.js
console.log('start');
const charts = await import.defer('./heavy.js');
console.log('namespace ready, not evaluated yet');
console.log(charts.format(7));
start
namespace ready, not evaluated yet
heavy.js evaluated
#7
Rolldown split heavy.js into its own chunk, loaded it, and still delayed evaluation until charts.format was accessed.
Current limitations
From the release notes and the experimental.importDefer docs:
- Dev mode and Vite are not supported yet. This is a Rolldown build feature for now.
- If your build contains a pattern Rolldown can’t defer yet, it falls back to a normal import with a warning that explains why.
- The 1.4 changelog lists support for deferred evaluation with external modules, in all output formats, and in builds with more than one chunk.
Treat it as experimental. It’s a good fit for CLIs, server bundles and libraries with expensive optional features. It’s not something to rely on for app-wide lazy loading yet.
Breaking changes to check before upgrading
1. experimental.nativeMagicString was removed
Native MagicString is now always on, and meta.magicString is also available in renderChunk hooks. Delete the option from your config to avoid an invalid-option warning:
export default defineConfig({
- experimental: { nativeMagicString: true },
});
2. Built-in plugins from a different Rolldown version now throw
Built-in plugins such as dynamicImportVarsPlugin() created by a different version of rolldown now throw BUILTIN_PLUGIN_VERSION_MISMATCH instead of being silently ignored. This usually means you have two copies installed, often one direct and one pulled in by a framework. Check with:
npm ls rolldown
# or
pnpm why rolldown
Then dedupe so only one version remains. Plugins created by 1.3.4 or earlier are still ignored, because they don’t carry version information.
3. require() of a bundled ES module returns the same object
Repeated require() calls to the same bundled ES module now return the same object, matching Node.js, Rollup and webpack. I confirmed it with a CommonJS entry:
// entry.cjs
const a = require('./esm.mjs');
const b = require('./esm.mjs');
console.log('same object:', a === b);
$ npx rolldown entry.cjs --platform node --format cjs -d out && node out/entry.js
same object: true
In 1.3.4 this was false. If any code depended on getting a fresh object each time (for example to mutate it per caller), it will now share state.
Also new
The 1.4.0 changelog also lists an experimental persistent scan cache and exposes the TransformExtraOptions type. See the full changelog for details.
Upgrade checklist
npm install -D [email protected]and run your build.- Remove
experimental.nativeMagicStringif it’s set. - Run
npm ls rolldownand fix any duplicate versions. - Search CommonJS code for patterns that relied on separate
require()results. - Optionally, enable
experimental.importDeferand try it on one heavy optional module.
Takeaway
Rolldown 1.4 is the first mainstream bundler release where you can try import defer with real output today. It keeps code synchronous while skipping work you don’t need. Turn it on in a branch, check startup timing, and keep an eye on the three default-behaviour changes when you upgrade.
