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. For each module, both the resolver and transformer search upward from the module's directory, starting at the nearest tsconfig.json. If it has references, Rolldown checks each referenced project's files/include/exclude and uses the first one that matches the file. If no reference matches, it checks the tsconfig.json's own files/include/exclude. If the file matches neither, Rolldown continues upward to the next tsconfig.json and repeats. If no tsconfig.json matches the file, no config is applied (no paths/baseUrl), the same as TypeScript.
Whether an include glob matches a file depends on its extension: by default only TypeScript files (.ts/.tsx/.mts/.cts) match, plus .js/.jsx/.mjs/.cjs when allowJs is enabled. A glob that names an explicit extension (for example src/**/*.vue) matches that extension verbatim, so a non-TS file can pick up the project's paths/baseUrl. (files lists exact paths and matches them regardless of extension or allowJs)
If the tsconfig has references, Rolldown resolves them the way TypeScript does: a referenced project that includes the file takes precedence over the root, and the first matching reference wins. Each referenced project matches with its own compilerOptions (such as allowJs). If no referenced project includes the file, Rolldown falls back to the root's own files/include/exclude. A solution-style root (only references with an explicit empty files/include, as Vite scaffolds) has no file patterns of its own, so once none of its references match either, it does not own the file, and discovery continues in the parent directories as described above.
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 metadatastrictNullChecks(falling back tostrict): Controls whethernull/undefinedare elided from nullable-uniondesign:typedecorator metadata, and only applies whenemitDecoratorMetadatais enabled. When neither is set it defaults to enabled, matching TypeScript 6.0+ (wherestrictis on by default)verbatimModuleSyntax: 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