Interface: OutputOptions
Properties
advancedChunks?
- Type:
optionaladvancedChunks:object
Allows you to do manual chunking. For deeper understanding, please refer to the in-depth documentation.
groups?
- Type:
optionalgroups:object[]
Groups to be used for advanced chunking.
includeDependenciesRecursively?
Type:
optionalincludeDependenciesRecursively:booleanType:
booleanDefault:
true
By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
If you want to disable this behavior, it's recommended to both set
preserveEntrySignatures: false | 'allow-extension'strictExecutionOrder: true
to avoid generating invalid chunks.
maxModuleSize?
Type:
optionalmaxModuleSize:numberType:
number
Global fallback of {group}.maxModuleSize, if it's not specified in the group.
maxSize?
Type:
optionalmaxSize:numberType:
number
Global fallback of {group}.maxSize, if it's not specified in the group.
minModuleSize?
Type:
optionalminModuleSize:numberType:
number
Global fallback of {group}.minModuleSize, if it's not specified in the group.
minShareCount?
Type:
optionalminShareCount:numberType:
number
Global fallback of {group}.minShareCount, if it's not specified in the group.
minSize?
Type:
optionalminSize:numberType:
number
Global fallback of {group}.minSize, if it's not specified in the group.
assetFileNames?
- Type:
optionalassetFileNames:string|AssetFileNamesFunction
banner?
- Type:
optionalbanner:string|AddonFunction
chunkFileNames?
- Type:
optionalchunkFileNames:string|ChunkFileNamesFunction
cleanDir?
- Type:
optionalcleanDir:boolean
- Type:
boolean - Default:
false
Clean output directory before emitting output.
cssChunkFileNames?
- Type:
optionalcssChunkFileNames:string|ChunkFileNamesFunction
cssEntryFileNames?
- Type:
optionalcssEntryFileNames:string|ChunkFileNamesFunction
dir?
- Type:
optionaldir:string
entryFileNames?
- Type:
optionalentryFileNames:string|ChunkFileNamesFunction
esModule?
- Type:
optionalesModule:boolean|"if-default-prop"
exports?
- Type:
optionalexports:"auto"|"named"|"default"|"none"
extend?
- Type:
optionalextend:boolean
externalLiveBindings?
- Type:
optionalexternalLiveBindings:boolean
file?
- Type:
optionalfile:string
footer?
- Type:
optionalfooter:string|AddonFunction
format?
- Type:
optionalformat:ModuleFormat
Expected format of generated code.
'es','esm'and'module'are the same format, all stand for ES module.'cjs'and'commonjs'are the same format, all stand for CommonJS module.'iife'stands for Immediately Invoked Function Expression.'umd'stands for Universal Module Definition.
Default
'esm'generatedCode?
- Type:
optionalgeneratedCode:Partial<GeneratedCodeOptions>
globals?
- Type:
optionalglobals:Record<string,string> |GlobalsFunction
hashCharacters?
- Type:
optionalhashCharacters:"base64"|"base36"|"hex"
hoistTransitiveImports?
- Type:
optionalhoistTransitiveImports:false
inlineDynamicImports?
- Type:
optionalinlineDynamicImports:boolean
intro?
- Type:
optionalintro:string|AddonFunction
keepNames?
- Type:
optionalkeepNames:boolean
Keep function and class names after bundling.
When enabled, the bundler will preserve the original names of functions and classes in the output, which is useful for debugging and error stack traces.
Default
falselegalComments?
- Type:
optionallegalComments:"none"|"inline"
Control comments in the output.
none: no commentsinline: preserve comments that contain@license,@preserveor starts with//!/*!
manualChunks?
- Type:
optionalmanualChunks:ManualChunksFunction
- Type:
((moduleId: string, meta: { getModuleInfo: (moduleId: string) => ModuleInfo | null }) => string | NullValue) - Object form is not supported.
WARNING
- This option is deprecated. Please use
advancedChunksinstead. - If
manualChunksandadvancedChunksare both specified,manualChunksoption will be ignored.
You could use this option for migration purpose. Under the hood,
{
manualChunks: (moduleId, meta) => {
if (moduleId.includes('node_modules')) {
return 'vendor';
}
return null;
}
}will be transformed to
{
advancedChunks: {
groups: [
{
name(moduleId) {
if (moduleId.includes('node_modules')) {
return 'vendor';
}
return null;
},
},
],
}
}Deprecated
Please use advancedChunks instead.
minify?
- Type:
optionalminify:boolean|MinifyOptions|"dce-only"
Control code minification.
true: Enable full minification including code compression and dead code eliminationfalse: Disable minification (default)'dce-only': Only perform dead code elimination without code compressionMinifyOptions: Fine-grained control over minification settings
Default
falseminifyInternalExports?
- Type:
optionalminifyInternalExports:boolean
- Type:
boolean - Default:
truefor formatesor ifoutput.minifyistrueor object,falseotherwise
Whether to minify internal exports.
name?
- Type:
optionalname:string
outro?
- Type:
optionaloutro:string|AddonFunction
paths?
- Type:
optionalpaths:Record<string,string> |PathsFunction
Maps external module IDs to paths.
Allows customizing the path used when importing external dependencies. This is particularly useful for loading dependencies from CDNs or custom locations.
- Object form: Maps module IDs to their replacement paths
- Function form: Takes a module ID and returns its replacement path
Examples
{
paths: {
'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
}
}{
paths: (id) => {
if (id.startsWith('lodash')) {
return `https://cdn.jsdelivr.net/npm/${id}`
}
return id
}
}plugins?
- Type:
optionalplugins:RolldownOutputPluginOption
polyfillRequire?
- Type:
optionalpolyfillRequire:boolean
postBanner?
- Type:
optionalpostBanner:string|AddonFunction
Similar to banner option, but will run after the renderChunk hook and builtin minification.
postFooter?
- Type:
optionalpostFooter:string|AddonFunction
Similar to footer option, but will run after the renderChunk hook and builtin minification.
preserveModules?
- Type:
optionalpreserveModules:boolean
preserveModulesRoot?
- Type:
optionalpreserveModulesRoot:string
sanitizeFileName?
- Type:
optionalsanitizeFileName:boolean|SanitizeFileNameFunction
sourcemap?
- Type:
optionalsourcemap:boolean|"inline"|"hidden"
sourcemapBaseUrl?
- Type:
optionalsourcemapBaseUrl:string
sourcemapDebugIds?
- Type:
optionalsourcemapDebugIds:boolean
sourcemapIgnoreList?
- Type:
optionalsourcemapIgnoreList:boolean|StringOrRegExp|SourcemapIgnoreListOption
Control which source files are included in the sourcemap ignore list. Files in the ignore list are excluded from debugger stepping and error stack traces.
false: Include all source files in the ignore listtrue: Include no source files in the ignore liststring: Files containing this string in their path will be included in the ignore listRegExp: Files matching this regular expression will be included in the ignore listfunction: Custom function(source: string, sourcemapPath: string) => booleanto determine if a source should be ignored
Performance
Using static values (boolean, string, or RegExp) is significantly more performant than functions. Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
Examples
// ✅ Preferred: Use RegExp for better performance
sourcemapIgnoreList: /node_modules/
// ✅ Preferred: Use string pattern for better performance
sourcemapIgnoreList: "vendor"
// ! Use sparingly: Function calls have high overhead
sourcemapIgnoreList: (source, sourcemapPath) => {
return source.includes('node_modules') || source.includes('.min.');
}default: /node_modules/
sourcemapPathTransform?
- Type:
optionalsourcemapPathTransform:SourcemapPathTransformOption
topLevelVar?
- Type:
optionaltopLevelVar:boolean
virtualDirname?
- Type:
optionalvirtualDirname:string