Interface: WatchOptions
Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:655
Extends
Properties
checks?
optional checks: ChecksOptions;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1951
Controls which warnings are emitted during the build process. Each option can be set to true (emit warning) or false (suppress warning).
Inherited from
context?
optional context: string;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1990
The value of this at the top level of each output chunk. For IIFE and UMD formats, this defaults to 'window' or 'global' depending on the platform.
Example
Set custom context
export default {
context: 'globalThis',
output: {
format: 'iife',
},
}Use window for browser builds
export default {
context: 'window',
platform: 'browser',
output: {
format: 'iife',
},
}./docs/context.md
Inherited from
cwd?
optional cwd: string;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1671
The working directory to use when resolving relative paths in the configuration.
Default
process.cwd()Inherited from
devtools?
optional devtools: object;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1953
sessionId?
optional sessionId: string;Inherited from
experimental?
optional experimental: object;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1753
Experimental features that may change in future releases and can introduce behavior change without a major version bump.
attachDebugInfo?
optional attachDebugInfo: AttachDebugOptions;Attach debug information to the output bundle.
Available modes:
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.
WARNING
You shouldn't use full in the production build.
Default
'simple'chunkImportMap?
optional chunkImportMap:
| 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
{
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'];
}
}
}
]
}TIP
If you want to learn more, you can check out the example here: examples/chunk-import-map
Default
falsechunkModulesOrder?
optional chunkModulesOrder: ChunkModulesOrder;Control which order should use when rendering modules in chunk.
Available options:
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)NOTE
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).
Default
'exec-order'devMode?
optional devMode: DevModeOptions;disableLiveBindings?
optional disableLiveBindings: boolean;Disable live bindings for exported variables.
Default
falseincrementalBuild?
optional incrementalBuild: boolean;Enable incremental build support. Required to be used with watch mode.
Default
falsenativeMagicString?
optional nativeMagicString: boolean;Use native Rust implementation of MagicString for source map generation.
MagicString 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.
Benefits
- Improved Performance: The native Rust implementation is typically faster than the JavaScript version, especially for large codebases with extensive source maps.
- Background Processing: Source map generation is performed asynchronously in a background thread, allowing the main bundling process to continue without blocking. This parallel processing can significantly reduce overall build times when working with JavaScript transform hooks.
- Better Integration: Seamless integration with rolldown's native Rust architecture.
Example
export default {
experimental: {
nativeMagicString: true,
},
output: {
sourcemap: true,
},
}NOTE
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
Default
falseonDemandWrapping?
optional onDemandWrapping: boolean;Enable on-demand wrapping of modules.
Default
falseresolveNewUrlToAsset?
optional resolveNewUrlToAsset: boolean;When enabled, new URL() calls will be transformed to a stable asset URL which includes the updated name and content hash. It is necessary to pass import.meta.url as the second argument to the new URL constructor, otherwise no transform will be applied.
WARNING
JavaScript and TypeScript files referenced via new URL('./file.js', import.meta.url) or new URL('./file.ts', import.meta.url) will not be transformed or bundled. The file will be copied as-is, meaning TypeScript files remain untransformed and dependencies are not resolved.
The expected behavior for JS/TS files is still being discussed and may change in future releases. See #7258 for more context.
Example
// main.js
const url = new URL('./styles.css', import.meta.url)
console.log(url)
// Example output after bundling WITHOUT the option (default)
const url = new URL('./styles.css', import.meta.url)
console.log(url)
// Example output after bundling WITH `experimental.resolveNewUrlToAsset` set to `true`
const url = new URL('assets/styles-CjdrdY7X.css', import.meta.url)
console.log(url)Default
falsestrictExecutionOrder?
optional strictExecutionOrder: boolean;Lets modules be executed in the order they are declared.
This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
WARNING
Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
Default
falsetransformHiresSourcemap?
optional transformHiresSourcemap: boolean | "boundary";Enable high-resolution source maps for transform operations.
Default
falseviteMode?
optional viteMode: boolean;Enable Vite compatible mode.
Default
falseInherited from
external?
optional external: ExternalOption;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1595
Specifies which modules should be treated as external and not bundled. External modules will be left as import statements in the output. ./docs/external.md
Inherited from
input?
optional input: InputOption;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1589
Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the cwd option. ./docs/input.md
Inherited from
logLevel?
optional logLevel: LogLevelOption;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1701
Controls the verbosity of console logging during the build.
Default
'info'Inherited from
makeAbsoluteExternalsRelative?
optional makeAbsoluteExternalsRelative: MakeAbsoluteExternalsRelative;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1952
Inherited from
InputOptions.makeAbsoluteExternalsRelative
moduleTypes?
optional moduleTypes: ModuleTypes;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1749
Maps file patterns to module types, controlling how files are processed. This is conceptually similar to esbuild's loader option, allowing you to specify how different file extensions should be handled.
Inherited from
onLog?
optional onLog: OnLogFunction;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1705
Custom handler for logs. Called for each log message before it's written to the console.
Inherited from
onwarn?
optional onwarn: OnwarnFunction;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1745
Custom handler for warnings during the build process.
Deprecated
Deprecated
This is a legacy API. Consider using onLog instead for better control over all log types.
Migration to onLog
To migrate from onwarn to onLog, check the level parameter to filter for warnings:
// Before: Using `onwarn`
export default {
onwarn(warning, defaultHandler) {
// Suppress certain warnings
if (warning.code === 'CIRCULAR_DEPENDENCY') return
// Handle other warnings with default behavior
defaultHandler(warning)
},
}// After: Using `onLog`
export default {
onLog(level, log, defaultHandler) {
// Handle only warnings (same behavior as `onwarn`)
if (level === 'warn') {
// Suppress certain warnings
if (log.code === 'CIRCULAR_DEPENDENCY') return
// Handle other warnings with default behavior
defaultHandler(level, log)
} else {
// Let other log levels pass through
defaultHandler(level, log)
}
},
}Inherited from
optimization?
optional optimization: OptimizationOptions;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1965
Configure optimization features for the bundler.
Inherited from
output?
optional output:
| OutputOptions
| OutputOptions[];Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:656
platform?
optional platform: "browser" | "node" | "neutral";Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1685
Expected platform where the code run.
When the platform is set to neutral:
- When bundling is enabled the default output format is set to esm, which uses the export syntax introduced with ECMAScript 2015 (i.e. ES6). You can change the output format if this default is not appropriate.
- The main fields setting is empty by default. If you want to use npm-style packages, you will likely have to configure this to be something else such as main for the standard main field used by node.
- The conditions setting does not automatically include any platform-specific values.
Default
- 'node' if the format is 'cjs'
- 'browser' for other formats ./docs/platform.md
Inherited from
plugins?
optional plugins: RolldownPluginOption;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1590
Inherited from
preserveEntrySignatures?
optional preserveEntrySignatures: false | "strict" | "allow-extension" | "exports-only";Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1961
Controls how entry chunk exports are preserved. This determines whether Rolldown needs to create facade chunks (additional wrapper chunks) to maintain the exact export signatures of entry modules, or whether it can combine entry modules with other chunks for optimization.
Default
'strict' ./docs/preserve-entry-signatures.md
Inherited from
InputOptions.preserveEntrySignatures
resolve?
optional resolve: object;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1596
alias?
optional alias: Record<string, string | false | string[]>;Example
resolve: {
alias: {
'@': '/src',
'utils': './src/utils',
}
}WARNING
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
aliasFields?
optional aliasFields: string[][];Fields in package.json to check for aliased paths.
conditionNames?
optional conditionNames: string[];Condition names to use when resolving exports in package.json. Defaults based on platform and import kind:
- Browser platform:
["import", "browser", "default"]for import statements,["require", "browser", "default"]for require() calls - Node platform:
["import", "node", "default"]for import statements,["require", "node", "default"]for require() calls - Neutral platform:
["import", "default"]for import statements,["require", "default"]for require() calls
exportsFields?
optional exportsFields: string[][];Fields in package.json to check for exports.
extensionAlias?
optional extensionAlias: 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'] }.
extensions?
optional extensions: string[];Extensions to try when resolving files. These are tried in order from first to last.
Default
;['.tsx', '.ts', '.jsx', '.js', '.json']mainFields?
optional mainFields: string[];Fields in package.json to check for entry points. Defaults based on platform:
- Node:
['main', 'module'] - Browser:
['browser', 'module', 'main'] - Neutral:
[](relies on exports field)
mainFiles?
optional mainFiles: string[];Filenames to try when resolving directories.
Default
;['index']modules?
optional modules: string[];Directories to search for modules.
Default
;['node_modules']symlinks?
optional symlinks: boolean;Whether to follow symlinks when resolving modules.
Default
truetsconfigFilename?
optional tsconfigFilename: string;Deprecated
Use the top-level tsconfig option instead.
Inherited from
shimMissingExports?
optional shimMissingExports: boolean;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1691
When true, creates shim variables for missing exports instead of throwing an error.
Default
false ./docs/shim-missing-exports.md
Inherited from
InputOptions.shimMissingExports
transform?
optional transform: TransformOptions;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1946
Configure 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.
Inherited from
treeshake?
optional treeshake: boolean | TreeshakingOptions;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1696
Controls tree-shaking (dead code elimination). When true, unused code will be removed from the bundle to reduce bundle size.
Default
trueInherited from
tsconfig?
optional tsconfig: string | true;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1996
Configures TypeScript configuration file resolution and usage. ./docs/tsconfig.md
Default
undefined (no tsconfig resolution)Inherited from
watch?
optional watch: false | WatcherOptions;Defined in: node_modules/.pnpm/rolldown@1.0.0-beta.58/node_modules/rolldown/dist/shared/define-config-twT5HTur.d.mts:1947