OptionalchecksOptionalcontextOptionalcwdOptionaldebugOptionalexperimentalOptionalattachDebugInfo?: AttachDebugOptionsOptionalchunkImportMap?: boolean | { baseUrl?: string; fileName?: string }Enables automatic generation of a chunk import map asset during build.
This map only includes chunks with hashed filenames, where keys are derived from the facade module name or primary chunk name. It produces stable and unique hash-based filenames, effectively preventing cascading cache invalidation caused by content hashes and maximizing browser cache reuse.
The output defaults to importmap.json unless overridden via fileName. A base URL prefix
(default "/") can be applied to all paths. The resulting JSON is a valid import map and can be
directly injected into HTML via <script type="importmap">.
Example configuration snippet:
{
experimental: {
chunkImportMap: {
baseUrl: '/',
fileName: 'importmap.json'
}
},
plugins: [
{
name: 'inject-import-map',
generateBundle(_, bundle) {
const chunkImportMap = bundle['importmap.json'];
if (chunkImportMap?.type === 'asset') {
const htmlPath = path.resolve('index.html');
let html = fs.readFileSync(htmlPath, 'utf-8');
html = html.replace(
/<script\s+type="importmap"[^>]*>[\s\S]*?</script>/i,
`<script type="importmap">${chunkImportMap.source}</script>`
);
fs.writeFileSync(htmlPath, html);
delete bundle['importmap.json'];
}
}
}
]
}
If you want to learn more, you can check out the example here: examples/chunk-import-map
OptionalchunkModulesOrder?: ChunkModulesOrderControl which order should use when rendering modules in chunk
Type: `'exec-order' | 'module-id'
Default: 'exec-order'
exec-order: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
module-id: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
Try to sort the modules by their module id if possible(Since rolldown scope hoist all modules in the chunk, we only try to sort those modules by module id if we could ensure runtime behavior is correct after sorting).
OptionaldevMode?: DevModeOptionsOptionaldisableLiveBindings?: booleanOptionalincrementalBuild?: booleanRequired to be used with watch mode.
OptionalnativeMagicString?: booleanUse native Rust implementation of MagicString for source map generation.
booleanfalseMagicString is a JavaScript library commonly used by bundlers for string manipulation and source map generation. When enabled, rolldown will use a native Rust implementation of MagicString instead of the JavaScript version, providing significantly better performance during source map generation and code transformation.
export default {
experimental: {
nativeMagicString: true
},
output: {
sourcemap: true
}
}
This is an experimental feature. While it aims to provide identical behavior to the JavaScript implementation, there may be edge cases. Please report any discrepancies you encounter. For a complete working example, see examples/native-magic-string
OptionalonDemandWrapping?: booleanOptionalresolveNewUrlToAsset?: booleanOptionalstrictExecutionOrder?: booleanLets modules be executed in the order they are declared.
booleanfalseThis is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
OptionaltransformHiresSourcemap?: boolean | "boundary"OptionalviteMode?: booleanOptionalexternalOptionalinputOptionallogOptionalmakeOptionalmoduleOptionalonOptionalonwarnOptionaloptimizationOptionaloutputOptionalplatformExpected platform where the code run.
When the platform is set to neutral:
OptionalpluginsOptionalpreserveOptionalresolveOptionalalias?: Record<string, string | false | string[]>
resolve.alias will not call resolveId hooks of other plugin.
If you want to call resolveId hooks of other plugin, use viteAliasPlugin from rolldown/experimental instead.
You could find more discussion in this issue
OptionalaliasFields?: string[][]OptionalconditionNames?: string[]OptionalexportsFields?: string[][]OptionalextensionAlias?: Record<string, string[]>Map of extensions to alternative extensions.
With writing import './foo.js' in a file, you want to resolve it to foo.ts instead of foo.js.
You can achieve this by setting: extensionAlias: { '.js': ['.ts', '.js'] }.
Optionalextensions?: string[]OptionalmainFields?: string[]OptionalmainFiles?: string[]Optionalmodules?: string[]Optionalsymlinks?: booleanOptionaltsconfigFilename?: stringOptionalshimOptionaltransformConfigure how the code is transformed. This process happens after the transform hook.
To transpile legacy decorators, you could use
export default defineConfig({
transform: {
decorator: {
legacy: true,
},
},
})
For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
OptionaltreeshakeOptionaltsconfigConfigures TypeScript configuration file resolution and usage.
true: Auto-discovery mode (similar to Vite). For each module, both resolver and transformer
will find the nearest tsconfig.json. If the tsconfig has references, the file extension is
allowed, and the tsconfig's include/exclude patterns don't match the file, the referenced
tsconfigs will be searched for a match. Falls back to the original tsconfig if no match is found.string: Path to a specific tsconfig.json file (relative to cwd or absolute path).compilerOptions.paths and compilerOptions.baseUrl for path mapping
Priority: Top-level transform options always take precedence over tsconfig settings.
OptionalwatchOptionalwriteWrite the output to the file system
Attach debug information to the output bundle.
Type:
'none' | 'simple' | 'full'Default:
'simple'none: No debug information is attached.simple: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.full: Attach detailed debug information to the output bundle. These comments are using legal comment syntax, so they won't be removed by the minifier.You shouldn't use
fullin the production build.