Config Options
🚧 Under Construction
We are working on generating a more detailed reference. For now, please refer to Rollup's Config Options Reference and documentation on additional notable features.
InputOptions
​
input
​
plugins
​
external
​
resolve
​
resolve.alias
​
WARNING
resolve.alias
will not call resolveId
hooks of other plugin.
If you want to call resolveId
hooks of other plugin, use aliasPlugin
from rolldown/experimental
instead.
You could find more discussion in this issue
resolve.aliasFields
​
resolve.conditionNames
​
resolve.extensionAlias
​
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'] }
.
resolve.exportsFields
​
resolve.extensions
​
resolve.mainFields
​
resolve.mainFiles
​
resolve.modules
​
resolve.symlinks
​
resolve.tsconfigFilename
​
cwd
​
platform
​
Expected platform where the code run.
shimMissingExports
​
treeshake
​
logLevel
​
onLog
​
onwarn
​
moduleTypes
​
experimental
​
experimental.enableComposingJsPlugins
​
experimental.strictExecutionOrder
​
experimental.disableLiveBindings
​
experimental.viteMode
​
experimental.resolveNewUrlToAsset
​
experimental.hmr
​
experimental.attachDebugInfo
​
define
​
Replace global variables or property accessors with the provided values.
Examples ​
- Replace the global variable
IS_PROD
withtrue
export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
Result:
// Input
if (IS_PROD) {
console.log('Production mode')
}
// After bundling
if (true) {
console.log('Production mode')
}
- Replace the property accessor
process.env.NODE_ENV
with'production'
export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
Result:
// Input
if (process.env.NODE_ENV === 'production') {
console.log('Production mode')
}
// After bundling
if ('production' === 'production') {
console.log('Production mode')
}
inject
​
Inject import statements on demand.
Supported patterns ​
{
// import { Promise } from 'es6-promise'
Promise: ['es6-promise', 'Promise'],
// import { Promise as P } from 'es6-promise'
P: ['es6-promise', 'Promise'],
// import $ from 'jquery'
$: 'jquery',
// import * as fs from 'node:fs'
fs: ['node:fs', '*'],
// Inject shims for property access pattern
'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
}
profilerNames
​
jsx
​
false
disables the JSX parser, resulting in a syntax error if JSX syntax is used."preserve"
disables the JSX transformer, preserving the original JSX syntax in the output."react"
enables theclassic
JSX transformer."react-jsx"
enables theautomatic
JSX transformer.
transform
​
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.
watch
​
dropLabels
​
keepNames
​
checks
​
makeAbsoluteExternalsRelative
​
debug
​
debug.sessionId
​
preserveEntrySignatures
​
OutputOptions
​
dir
​
file
​
exports
​
hashCharacters
​
format
​
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.
sourcemap
​
sourcemapDebugIds
​
sourcemapIgnoreList
​
sourcemapPathTransform
​
banner
​
footer
​
intro
​
outro
​
extend
​
esModule
​
assetFileNames
​
entryFileNames
​
chunkFileNames
​
cssEntryFileNames
​
cssChunkFileNames
​
sanitizeFileName
​
minify
​
name
​
globals
​
externalLiveBindings
​
inlineDynamicImports
​
advancedChunks
​
Allows you to do manual chunking. For deeper understanding, please refer to the in-depth documentation.
advancedChunks.minSize
​
- Type:
number
Global fallback of {group}.minSize
, if it's not specified in the group.
advancedChunks.maxSize
​
- Type:
number
Global fallback of {group}.maxSize
, if it's not specified in the group.
advancedChunks.maxModuleSize
​
- Type:
number
Global fallback of {group}.maxModuleSize
, if it's not specified in the group.
advancedChunks.minModuleSize
​
- Type:
number
Global fallback of {group}.minModuleSize
, if it's not specified in the group.
advancedChunks.minShareCount
​
- Type:
number
Global fallback of {group}.minShareCount
, if it's not specified in the group.
advancedChunks.groups
​
Groups to be used for advanced chunking.
advancedChunks.groups.name
​
- Type:
string
Name of the group. It will be also used as the name of the chunk and replaced the [name]
placeholder in the chunkFileNames
option.
For example,
import { defineConfig } from 'rolldown';
export default defineConfig({
advancedChunks: {
groups: [
{
name: 'libs',
test: /node_modules/,
},
],
},
});
will create a chunk named libs-[hash].js
in the end.
advancedChunks.groups.test
​
- Type:
string | RegExp | ((id: string) => boolean | undefined | void);
Controls which modules are captured in this group.
- If
test
is a string, the module whose id contains the string will be captured. - If
test
is a regular expression, the module whose id matches the regular expression will be captured. - If
test
is a function, modules for whichtest(id)
returnstrue
will be captured. - If
test
is empty, any module will be considered as matched.
advancedChunks.groups.priority
​
- Type:
number
- Default:
0
Priority of the group. Group with higher priority will be chosen first to match modules and create chunks. When converting the group to a chunk, modules of that group will be removed from other groups.
If two groups have the same priority, the group whose index is smaller will be chosen.
For example,
import { defineConfig } from 'rolldown';
export default defineConfig({
advancedChunks: {
groups: [
{
name: 'react',
test: /node_modules/react/,
priority: 1,
},
{
name: 'other-libs',
test: /node_modules/,
priority: 2,
},
],
});
This is a clearly incorrect example. Though react
group is defined before other-libs
, it has a lower priority, so the modules in react
group will be captured in other-libs
group.
advancedChunks.groups.minSize
​
- Type:
number
- Default:
0
Minimum size of the desired chunk. If the accumulated size of the captured modules by this group is smaller than this value, it will be ignored. Modules in this group will fall back to the automatic chunking
if they are not captured by any other group.
advancedChunks.groups.minShareCount
​
- Type:
number
- Default:
1
Controls if a module should be captured based on how many entry chunks reference it.
advancedChunks.groups.maxSize
​
- Type:
number
- Default:
Infinity
If the accumulated size of the captured modules by this group is larger than this value, this group will be split into multiple groups that each has size close to this value.
advancedChunks.groups.maxModuleSize
​
- Type:
number
- Default:
Infinity
Controls a module could only be captured if its size is smaller or equal than this value.
advancedChunks.groups.minModuleSize
​
- Type:
number
- Default:
0
Controls a module could only be captured if its size is larger or equal than this value.
legalComments
​
Control comments in the output.
none
: no commentsinline
: preserve comments that contain@license
,@preserve
or starts with//!
/*!