Skip to content

Commit 1127396

Browse files
committed
chore: update
1 parent 75b9133 commit 1127396

File tree

37 files changed

+151
-243
lines changed

37 files changed

+151
-243
lines changed

packages/core/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ const composeDtsConfig = async (
15001500
banner: banner?.dts,
15011501
footer: footer?.dts,
15021502
redirect: redirect?.dts,
1503-
experiments: dts?.experiments,
1503+
tsgo: dts?.tsgo,
15041504
}),
15051505
],
15061506
};

packages/core/src/types/config.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,11 @@ export type Dts =
9595
*/
9696
alias?: Record<string, string>;
9797
/**
98-
* [Experimental] Whether to enable experimental features.
99-
* @defaultValue `{}`
100-
* @see {@link https://rslib.rs/config/lib/dts#dtsexperiments}
98+
* [Experimental] Whether to generate declaration files with `tsgo`.
99+
* @defaultValue `false`
100+
* @see {@link https://rslib.rs/config/lib/dts#dtstsgo}
101101
*/
102-
experiments?: {
103-
/**
104-
* [Experimental] Whether to generate declaration files with `tsgo`.
105-
* @defaultValue `false`
106-
* @see {@link https://rslib.rs/config/lib/dts#dtsexperimentstsgo}
107-
*/
108-
tsgo?: boolean;
109-
};
102+
tsgo?: boolean;
110103
}
111104
| boolean;
112105

packages/plugin-dts/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pluginDts({
136136
});
137137
```
138138

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.
139+
> When [tsgo](#tsgo) 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.
140140
141141
### alias
142142

@@ -282,19 +282,14 @@ import { foo } from './foo.mjs'; // expected output of './dist/bar.d.mts'
282282

283283
- 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).
284284

285-
### experiments
286-
287-
- **Type:** `{ tsgo?: boolean }`
288-
- **Default:** `{}`
289-
290-
Whether to enable experimental features.
291-
292-
#### experiments.tsgo
285+
### tsgo
293286

294287
- **Type:** `boolean`
295288
- **Default:** `false`
296289

297-
Whether to generate declaration files with [tsgo](https://github.com/microsoft/typescript-go).
290+
Whether to generate declaration files with [tsgo](https://github.com/microsoft/typescript-go), which can provide faster generation of declaration files, especially for large projects.
291+
292+
> This feature is currently an **experimental feature**. Since tsgo is still in the **experimental stage**, there may be some bugs and unresolved issues or limitations. So, make sure to fully test it in your project before enabling this option.
298293
299294
To enable this option, you need to:
300295

@@ -306,17 +301,21 @@ npm add @typescript/native-preview -D
306301

307302
> `@typescript/native-preview` requires Node.js 20.6.0 or higher.
308303
309-
2. Set `experiments.tsgo` to `true`.
304+
2. Set `tsgo` to `true`.
310305

311306
```js
312307
pluginDts({
313-
experiments: {
314-
tsgo: true,
315-
},
308+
tsgo: true,
316309
});
317310
```
318311

319-
> `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.
312+
3. In order to ensure the consistency of local development, you need to install the corresponding [VS Code Preview Extension](https://marketplace.visualstudio.com/items?itemName=TypeScriptTeam.native-preview) and add the following configuration in the VS Code settings:
313+
314+
```json
315+
{
316+
"typescript.experimental.useTsgo": true
317+
}
318+
```
320319

321320
## Contributing
322321

packages/plugin-dts/src/dts.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,8 @@ export async function generateDts(data: DtsGenOptions): Promise<void> {
135135
path: true,
136136
extension: false,
137137
},
138-
experiments = {
139-
tsgo: false,
140-
},
138+
tsgo,
141139
} = data;
142-
const { tsgo } = experiments;
143140
if (!isWatch) {
144141
logger.start(`generating declaration files... ${color.dim(`(${name})`)}`);
145142
}

packages/plugin-dts/src/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export type PluginDtsOptions = {
4444
banner?: string;
4545
footer?: string;
4646
redirect?: DtsRedirect;
47-
experiments?: {
48-
tsgo?: boolean;
49-
};
47+
tsgo?: boolean;
5048
};
5149

5250
export type DtsEntry = {
@@ -96,16 +94,15 @@ export const pluginDts = (options: PluginDtsOptions = {}): RsbuildPlugin => ({
9694
options.redirect.path = options.redirect.path ?? true;
9795
options.redirect.extension = options.redirect.extension ?? false;
9896
options.alias = options.alias ?? {};
99-
options.experiments = options.experiments ?? {};
100-
options.experiments.tsgo = options.experiments.tsgo ?? false;
97+
options.tsgo = options.tsgo ?? false;
10198

10299
const dtsPromises: Promise<TaskResult>[] = [];
103100
let promisesResult: TaskResult[] = [];
104101
let childProcesses: ChildProcess[] = [];
105102

106103
api.onBeforeEnvironmentCompile(
107104
async ({ isWatch, isFirstCompile, environment }) => {
108-
if (!isFirstCompile && !options.experiments?.tsgo) {
105+
if (!isFirstCompile && !options.tsgo) {
109106
return;
110107
}
111108

tests/integration/banner-footer/rslib.config.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ export default defineConfig({
9898
},
9999
dts: {
100100
bundle: true,
101-
experiments: {
102-
tsgo: true,
103-
},
101+
tsgo: true,
104102
},
105103
...bannerFooterConfig,
106104
}),
@@ -113,9 +111,7 @@ export default defineConfig({
113111
},
114112
dts: {
115113
bundle: true,
116-
experiments: {
117-
tsgo: true,
118-
},
114+
tsgo: true,
119115
},
120116
...bannerFooterConfig,
121117
}),
@@ -129,9 +125,7 @@ export default defineConfig({
129125
bundle: false,
130126
dts: {
131127
bundle: false,
132-
experiments: {
133-
tsgo: true,
134-
},
128+
tsgo: true,
135129
},
136130
source: {
137131
entry: {
@@ -150,9 +144,7 @@ export default defineConfig({
150144
bundle: false,
151145
dts: {
152146
bundle: false,
153-
experiments: {
154-
tsgo: true,
155-
},
147+
tsgo: true,
156148
},
157149
source: {
158150
entry: {
@@ -171,9 +163,7 @@ export default defineConfig({
171163
},
172164
dts: {
173165
bundle: true,
174-
experiments: {
175-
tsgo: true,
176-
},
166+
tsgo: true,
177167
},
178168
...bannerFooterConfig,
179169
}),

tests/integration/dts-tsgo/build/abort-on-error/rslib.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export default defineConfig({
99
bundle: false,
1010
build: true,
1111
abortOnError: false,
12-
experiments: {
13-
tsgo: true,
14-
},
12+
tsgo: true,
1513
},
1614
}),
1715
],

tests/integration/dts-tsgo/build/auto-extension/rslib.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ export default defineConfig({
1010
distPath: './dist/types',
1111
bundle: false,
1212
build: true,
13-
experiments: {
14-
tsgo: true,
15-
},
13+
tsgo: true,
1614
},
1715
}),
1816
],

tests/integration/dts-tsgo/build/basic/rslib.config.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export default defineConfig({
88
dts: {
99
bundle: false,
1010
build: true,
11-
experiments: {
12-
tsgo: true,
13-
},
11+
tsgo: true,
1412
},
1513
}),
1614
],

tests/integration/dts-tsgo/build/clean/rslib.config.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export default defineConfig({
99
distPath: './dist-types/esm',
1010
bundle: false,
1111
build: true,
12-
experiments: {
13-
tsgo: true,
14-
},
12+
tsgo: true,
1513
},
1614
source: {
1715
tsconfigPath: './tsconfig.esm.json',
@@ -23,9 +21,7 @@ export default defineConfig({
2321
distPath: './dist-types/cjs',
2422
bundle: false,
2523
build: true,
26-
experiments: {
27-
tsgo: true,
28-
},
24+
tsgo: true,
2925
},
3026
source: {
3127
tsconfigPath: './tsconfig.cjs.json',

0 commit comments

Comments
 (0)