Skip to content

Commit

Permalink
fix(module-tools): use tsc --clean to clear the tsbuildinfo and d.ts (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
10Derozan authored Dec 12, 2023
1 parent fa731a7 commit e4dd353
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/wet-beds-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/module-tools': patch
---

fix(module-tools): use tsc --clean to clear the tsbuildinfo and d.ts files
fix(module-tools): 使用 "tsc --clean" 来清理生成的 tsbuildinfo 和类型描述文件
17 changes: 16 additions & 1 deletion packages/solutions/module-tools/src/builder/clear.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fs, logger, chalk } from '@modern-js/utils';
import { fs, logger, chalk, execa } from '@modern-js/utils';
import type { BaseBuildConfig } from '../types';
import { i18n, localeKeys } from '../locale';
import { getTscBinPath } from '../utils';

export const clearBuildConfigPaths = async (
configs: BaseBuildConfig[],
Expand All @@ -12,5 +13,19 @@ export const clearBuildConfigPaths = async (
} else {
await fs.remove(config.outDir);
}

// tsc --build --clean
if (config.buildType === 'bundleless' && config.dts) {
const tscBinFile = await getTscBinPath(projectAbsRootPath);
const childProgress = execa(tscBinFile, ['--build', '--clean'], {
stdio: 'pipe',
cwd: projectAbsRootPath,
});
try {
await childProgress;
} catch (e) {
logger.error(e);
}
}
}
};

0 comments on commit e4dd353

Please sign in to comment.