Skip to content

Commit 40ec8a2

Browse files
committed
perf: rm buildinfo on demand
1 parent 37bc7ee commit 40ec8a2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/plugin-dts/src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ export const pluginDts = (options: PluginDtsOptions = {}): RsbuildPlugin => ({
9898
}
9999

100100
const tsConfigResult = loadTsconfig(tsconfigPath);
101+
const compilerOptions = tsConfigResult.options;
101102
const dtsEmitPath =
102103
options.distPath ??
103-
tsConfigResult.options.declarationDir ??
104+
compilerOptions.declarationDir ??
104105
config.output?.distPath?.root;
105106

106107
const jsExtension = extname(__filename);
@@ -123,7 +124,13 @@ export const pluginDts = (options: PluginDtsOptions = {}): RsbuildPlugin => ({
123124
}
124125

125126
// clean tsbuildinfo file
126-
await cleanTsBuildInfoFile(tsconfigPath, tsConfigResult);
127+
if (
128+
compilerOptions.composite ||
129+
compilerOptions.incremental ||
130+
options.build
131+
) {
132+
await cleanTsBuildInfoFile(tsconfigPath, tsConfigResult);
133+
}
127134

128135
const dtsGenOptions: DtsGenOptions = {
129136
...options,

packages/plugin-dts/src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,7 @@ export async function cleanTsBuildInfoFile(
263263
}
264264
}
265265

266-
await fsP.rm(tsbuildInfoFilePath, { force: true });
266+
if (await pathExists(tsbuildInfoFilePath)) {
267+
await fsP.rm(tsbuildInfoFilePath, { force: true });
268+
}
267269
}

0 commit comments

Comments
 (0)