tsconfig
- Type:
string|boolean - Optional
Configures TypeScript configuration file resolution and usage.
Options
Auto-discovery mode (true)
When set to true, Rolldown enables auto-discovery mode (similar to Vite). For each module, both the resolver and transformer will find the nearest tsconfig.json.
If the tsconfig has references, Rolldown resolves them the way TypeScript does: a referenced project that includes the file takes precedence over the root. Each referenced project uses its own allowJs, so a .js/.jsx/.mjs/.cjs file is only included by projects that enable it. If no referenced project includes the file, Rolldown falls back to the root tsconfig.
export default {
tsconfig: true,
};Explicit path (string)
Specifies the path to a specific TypeScript configuration file. You may provide a relative path (resolved relative to cwd) or an absolute path.
If the tsconfig has references, this mode behaves like auto-discovery mode for reference resolution.
export default {
tsconfig: './tsconfig.json',
};export default {
tsconfig: '/absolute/path/to/tsconfig.json',
};TIP
Rolldown respects references and include/exclude patterns in tsconfig, while esbuild does not. If you need esbuild-compatible behavior, specify a tsconfig without references. You can use extends to share the options between the two.
What's used from tsconfig
When a tsconfig is resolved, Rolldown uses different parts for different purposes:
Resolver
Uses the following for module path mapping:
compilerOptions.paths: Path mapping for module resolutioncompilerOptions.baseUrl: Base directory for path resolution
Transformer
Uses select compiler options including:
jsx: JSX transformation modeexperimentalDecorators: Enable decorator supportemitDecoratorMetadata: Emit decorator metadataverbatimModuleSyntax: Module syntax preservationuseDefineForClassFields: Class field semantics- And other TypeScript-specific options
Example
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@components/*": ["src/components/*"]
}
}
}With this configuration:
- JSX will use React's automatic runtime
- Path aliases like
@/utilswill resolve tosrc/utils
Priority
Top-level transform options always take precedence over tsconfig settings:
export default {
tsconfig: './tsconfig.json', // Has jsx: 'react-jsx'
transform: {
jsx: {
mode: 'classic', // This takes precedence
},
},
};TIP
For TypeScript projects, it's recommended to use tsconfig: true for auto-discovery or specify an explicit path to ensure consistent compilation behavior and enable path mapping.
Default
true