Notable Features
This page documents some notable features in Rolldown that do not have built-in equivalents in Rollup.
Platform presets
- Configurable via the
platformoption. - Default:
'node'forcjsoutput,'browser'otherwise - Possible values:
browser | node | neutral
Similar to esbuild's platform option, this option provides some sensible defaults regarding module resolution and how to handle process.env.NODE_ENV.
Notable differences from esbuild:
- The default output format is always
esmregardless of platform.
TIP
Rolldown does not polyfill Node built-ins when targeting the browser. You can opt-in to it with rolldown-plugin-node-polyfills.
Built-in transforms
Rolldown supports the following transforms out of the box, powered by Oxc. The transform is configurable via the transform option. The following transforms are supported:
- TypeScript
- Sets configurations based on the
tsconfig.jsonwhen thetsconfigoption is provided. - Supported legacy decorators and decorator metadata.
- Sets configurations based on the
- JSX
- Syntax lowering
- Automatically transforms modern syntax to be compatible with your defined target.
- Supports down to ES2015.
CJS support
Rolldown supports mixed ESM / CJS module graphs out of the box, without the need for @rollup/plugin-commonjs. It largely follows esbuild's semantics and passes all esbuild ESM / CJS interop tests.
See Bundling CJS for more details.
Module resolution
- Configurable via the
resolveoption - Powered by oxc-resolver, aligned with webpack's enhanced-resolve
Rolldown resolves modules based on TypeScript and Node.js' behavior by default, without the need for @rollup/plugin-node-resolve.
When top-level tsconfig option is provided, Rolldown will respect compilerOptions.paths in the specified tsconfig.json.
Define
- Configurable via the
transform.defineoption.
This feature provides a way to replace global identifiers with constant expressions. Aligns with the respective options in Vite and esbuild.
@rollup/plugin-replace behaves differently
Note it behaves differently from @rollup/plugin-replace as the replacement is AST-based, so the value to be replaced must be a valid identifier or member expression. Use the built-in replacePlugin for that purpose.
Inject
- Configurable via the
transform.injectoption.
This feature provides a way to shim global variables with a specific value exported from a module. This feature is equivalent of @rollup/plugin-inject and conceptually similar to esbuild's inject option.
Manual Code Splitting
- Configurable via
output.codeSplittingoption.
Rolldown allows controlling the chunking behavior granularly, similar to webpack's optimization.splitChunks feature.
See Manual Code Splitting for more details.
Module types
- ⚠️ Experimental
This is conceptually similar to esbuild's loader option, allowing users to globally associate file extensions to built-in module types via the moduleTypes option, or specify module type of a specific module in plugin hooks. It is discussed in more details here.
Minification
- Configurable via the
output.minifyoption.
The minification is powered by Oxc Minifier. See its documentation for more details.
