Notable Features
This page documents some notable features in Rolldown that do not have built-in equivalents in Rollup.
Platform presets
- Configurable via the
platform
option. - Default:
browser
- 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
esm
regardless of platform. - No
</script>
escape behavior when platform isbrowser
.
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.json
whentsconfig
option 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
resolve
option - 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
define
option.
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
inject
option.
This feature provides a way to shim global variables with a specific value exported from a module. This feature is equivalent of esbuild's inject
option and @rollup/plugin-inject
.
CSS bundling
- ⚠️ Experimental
Rolldown supports bundling CSS imported from JS out of the box. Note this feature currently does not support CSS Modules and minification.
Advanced Chunks
- ⚠️ Experimental
- Configurable via
output.advancedChunks
option.
Rolldown allows controlling the chunking behavior granularly, similar to webpack's optimization.splitChunks
feature.
See Advanced Chunks 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
- ⚠️ Experimental
- Configurable via the
output.minify
option.
The minification is powered by oxc-minifier
, which is currently in alpha and can still have bugs. We recommend thoroughly testing your output in production environments.
If you prefer an external minifier instead, Rolldown is compatible with Rollup minifier plugins, such as:
import { defineConfig } from 'rolldown';
import { minify } from 'rollup-plugin-esbuild';
export default defineConfig({
plugins: [minify()],
});
import { defineConfig } from 'rolldown';
import { minify } from 'rollup-plugin-swc3';
export default defineConfig({
plugins: [
minify({
module: true,
// swc's minify option here
mangle: {},
compress: {},
}),
],
});