You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[@microsoft/api-extractor](https://github.com/microsoft/rushstack/tree/main/apps/api-extractor) only supports bundle DTS for single entry. If you want to generate bundle DTS for multiple entries, you can add extra lib configuration in [lib](/config/lib) field to split multiple entries into multiple lib configurations.
92
+
93
+
:::
94
+
95
+
### dts.distPath
96
+
97
+
-**Type:**`string`
98
+
99
+
The output directory of DTS files.
100
+
101
+
#### Default Value
102
+
103
+
The default value follows the priority below:
104
+
105
+
1. The `dts.distPath` value in the current lib configuration.
106
+
2. The `declarationDir` value in the `tsconfig.json` file.
107
+
3. The [output.distPath.root](/config/rsbuild/output#outputdistpath) value in the current lib configuration.
108
+
109
+
#### Example
110
+
111
+
```ts title="rslib.config.ts" {5-7}
112
+
exportdefault {
113
+
lib: [
114
+
{
115
+
format: 'esm',
116
+
dts: {
117
+
distPath: './dist-types',
118
+
},
119
+
},
120
+
],
121
+
};
122
+
```
123
+
124
+
### dts.build
125
+
126
+
-**Type:**`boolean`
127
+
-**Default:**`false`
128
+
129
+
Determines whether to generate DTS files while building the project's references. This is equivalent to using the `--build` flag with the `tsc` command.
130
+
131
+
::: note
132
+
133
+
When this option is enabled, you must explicitly set `declarationDir` or `outDir` in `tsconfig.json` in order to meet the build requirements.
134
+
135
+
:::
136
+
137
+
### dts.abortOnError
138
+
139
+
-**Type:**`boolean`
140
+
-**Default:**`true`
141
+
142
+
Whether to abort the build process when an error occurs during DTS generation.
143
+
144
+
By default, type errors will cause the build to fail. When `abortOnError` is set to `false`, the build will still succeed even if there are type issues in the code:
145
+
146
+
```ts title="rslib.config.ts" {5-7}
147
+
exportdefault {
148
+
lib: [
149
+
{
150
+
format: 'esm',
151
+
dts: {
152
+
abortOnError: false,
153
+
},
154
+
},
155
+
],
156
+
};
157
+
```
158
+
159
+
::: warning
160
+
161
+
When this configuration is disabled, there is no guarantee that the type files will be generated correctly.
162
+
163
+
:::
164
+
165
+
### dts.autoExtension
166
+
167
+
-**Type:**`boolean`
168
+
-**Default:**`false`
169
+
170
+
Whether to automatically set the DTS file extension based on the [format](/config/lib/format) option.
171
+
172
+
#### Default Extension
173
+
174
+
By default that when `dts.autoExtension` is `false`, the DTS file extension will be `.d.ts`.
175
+
176
+
When `dts.autoExtension` is set to `true`, the DTS file extension will be:
177
+
178
+
-`.d.ts` with `esm` format and `.d.cts` with `cjs` format when `type: module` in `package.json`.
179
+
180
+
-`.d.ts` with `cjs` format and `.d.mts` with `esm` format when `type: commonjs` or no `type` field in `package.json`.
181
+
182
+
::: note
183
+
184
+
It follows the same logic as [lib.autoExtension](/config/lib/auto-extension), but the default value is different since the DTS file extension may cause some issues with different module resolution strategies.
Copy file name to clipboardExpand all lines: website/docs/en/guide/advanced/dts.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,3 +59,5 @@ import { PackageManagerTabs } from '@theme';
59
59
- Set `dts: { bundle: true }` in the Rslib configuration file.
60
60
61
61
You can refer to [lib.dts](/config/lib/dts) for more details about DTS configuration.
62
+
63
+
- Specify which third-party package types need to be bundled, refer to the [Handle Third-Party Dependencies](/guide/advanced/third-party-deps) documentation for more details about externals related configurations.
0 commit comments