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
Copy file name to clipboardExpand all lines: packages/plugin-dts/README.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,8 @@ pluginDts({
136
136
});
137
137
```
138
138
139
+
> When [experiments.tsgo](#experimentstsgo) is enabled, if the project also enables [build](#build) or emits declaration files with different extensions to the same directory, `dtsExtension` may not work correctly.
140
+
139
141
### alias
140
142
141
143
-**Type:**`Record<string, string>`
@@ -280,6 +282,40 @@ import { foo } from './foo.mjs'; // expected output of './dist/bar.d.mts'
280
282
281
283
- When set to `false`, the file extension will remain unchanged from the original import path in the rewritten import path of the output file (regardless of whether it is specified or specified as any value).
282
284
285
+
### experiments
286
+
287
+
-**Type:**`{ tsgo?: boolean }`
288
+
-**Default:**`{}`
289
+
290
+
Whether to enable experimental features.
291
+
292
+
#### experiments.tsgo
293
+
294
+
-**Type:**`boolean`
295
+
-**Default:**`false`
296
+
297
+
Whether to generate declaration files with [tsgo](https://github.com/microsoft/typescript-go).
298
+
299
+
To enable this option, you need to:
300
+
301
+
1. Install [@typescript/native-preview](https://www.npmjs.com/package/@typescript/native-preview) as a development dependency.
302
+
303
+
```bash
304
+
npm add @typescript/native-preview -D
305
+
```
306
+
307
+
2. Set `experiments.tsgo` to `true`.
308
+
309
+
```js
310
+
pluginDts({
311
+
experiments: {
312
+
tsgo:true,
313
+
},
314
+
});
315
+
```
316
+
317
+
> `tsgo` can provide faster generation of declaration files, especially for large projects. However, since `tsgo` is still experimental, there may be unresolved issues or limitations. Therefore, please make sure to thoroughly test it in your project before enabling this option.
318
+
283
319
## Contributing
284
320
285
321
Please read the [Contributing Guide](https://github.com/web-infra-dev/rslib/blob/main/CONTRIBUTING.md).
Copy file name to clipboardExpand all lines: website/docs/en/config/lib/dts.mdx
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,9 @@ type Dts =
15
15
abortOnError?:boolean;
16
16
autoExtension?:boolean;
17
17
alias?:Record<string, string>;
18
+
experiments?: {
19
+
tsgo?:boolean;
20
+
};
18
21
}
19
22
|boolean;
20
23
```
@@ -216,7 +219,9 @@ When `dts.autoExtension` is set to `true`, the declaration file extension will b
216
219
217
220
::: note
218
221
219
-
It follows the same logic as [lib.autoExtension](/config/lib/auto-extension), but the default value is different since the declaration file extension may cause some issues with different module resolution strategies.
222
+
1. It follows the same logic as [lib.autoExtension](/config/lib/auto-extension), but the default value is different since the declaration file extension may cause some issues with different module resolution strategies.
223
+
224
+
2. When [dts.experiments.tsgo](/config/lib/dts#dtsexperimentstsgo) is enabled, if the project also enables [dts.build](/config/lib/dts#dtsbuild) or emits declaration files with different extensions to the same directory, `dts.autoExtension` may not work correctly.
220
225
221
226
:::
222
227
@@ -245,3 +250,42 @@ export default {
245
250
],
246
251
};
247
252
```
253
+
254
+
### dts.experiments
255
+
256
+
-**Type:**`{ tsgo?: boolean }`
257
+
-**Default:**`{}`
258
+
259
+
Whether to enable experimental features.
260
+
261
+
#### dts.experiments.tsgo
262
+
263
+
-**Type:**`boolean`
264
+
-**Default:**`false`
265
+
266
+
Whether to generate declaration files with [tsgo](https://github.com/microsoft/typescript-go).
267
+
268
+
To enable this option, you need to install [@typescript/native-preview](https://www.npmjs.com/package/@typescript/native-preview) as a development dependency.
`tsgo` can provide faster generation of declaration files, especially for large projects. However, since `tsgo` is still experimental, there may be unresolved issues or limitations. Therefore, please make sure to thoroughly test it in your project before enabling this option.
Copy file name to clipboardExpand all lines: website/docs/en/guide/advanced/dts.mdx
+69-8Lines changed: 69 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,23 +40,83 @@ Bundleless declaration files involves generating a separate declaration file for
40
40
41
41
## How to generate declaration files in Rslib
42
42
43
-
Rslib defaults to generating bundleless declaration files, which using [TypeScript Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) and bundle declaration files is also supported by [API Extractor](https://api-extractor.com/).
44
-
45
-
If you want to generate bundleless declaration files, you can:
46
-
47
-
- Set `dts: true` or `dts: { bundle: false }` in the Rslib configuration file.
43
+
Rslib supports generating declaration files using both the [TypeScript Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) and [tsgo](https://github.com/microsoft/typescript-go), and also supports bundling declaration files with [API Extractor](https://api-extractor.com/).
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.
119
+
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) or [tsgo](https://github.com/microsoft/typescript-go) generates only declaration files.
60
120
61
121
```json
62
122
{
@@ -84,6 +144,7 @@ The priority from highest to lowest of final output directory of declaration fil
84
144
|[dts.abortOnError](/config/lib/dts#dtsabortonerror)| Whether to abort the build process when an error occurs during declaration files generation. |
85
145
|[dts.autoExtension](/config/lib/dts#dtsautoextension)| Whether to automatically set the declaration file extension based on the [format](/config/lib/format) option. |
86
146
|[dts.alias](/config/lib/dts#dtsalias)| The path alias of the declaration files. |
147
+
|[dts.experiments.tsgo](/config/lib/dts#dtsexperimentstsgo)| Whether to generate declaration files with [tsgo](https://github.com/microsoft/TypeScript/pull/48729). |
87
148
|[banner.dts](/config/lib/banner#bannerdts)| Inject content into the top of each declaration output file. |
88
149
|[footer.dts](/config/lib/footer#footerdts)| Inject content into the bottom of each declaration file. |
89
150
|[redirect.dts.path](/config/lib/redirect#redirectdtspath)| Whether to automatically redirect the import paths of TypeScript declaration output files. |
0 commit comments