Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions website/docs/en/guide/advanced/dts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ import { PackageManagerTabs } from '@theme';

2. Set `dts: { bundle: true }` in the Rslib configuration file.

It should be noted that during the generation of declaration files, Rslib will automatically enforce some configuration options in `tsconfig.json` to ensure that the [TypeScript Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) generates only declaration files.

```json
{
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true
}
}
```

The priority from highest to lowest of final output directory of declaration files:

- The configuration option [dts.distPath](/config/lib/dts#dtsdistpath)
- The configuration option `declarationDir` in `tsconfig.json`
- The configuration option [output.distPath.root](/config/rsbuild/output#outputdistpath)

::: tip

You can refer to [lib.dts](/config/lib/dts) for more details about declaration files configuration.
Expand Down
18 changes: 18 additions & 0 deletions website/docs/zh/guide/advanced/dts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ import { PackageManagerTabs } from '@theme';

2. 在 Rslib 配置文件中设置 `dts: { bundle: true }`。

需要注意的是,Rslib 在生成类型声明文件的过程中,默认会强制设置 `tsconfig.json` 中的一些配置项以保证 [TypeScript Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) 能够仅生成类型声明文件。

```json
{
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true
}
}
```

最终类型声明文件输出目录的优先级从高到低为:

- [dts.distPath](/config/lib/dts#dtsdistpath) 配置项
- `tsconfig.json` 中的 `declarationDir` 配置项
- [output.distPath.root](/config/rsbuild/output#outputdistpath) 配置项

::: tip

你可以参考 [lib.dts](/config/lib/dts) 获取更多有关类型声明文件配置的详细信息。
Expand Down
Loading