From 923fee79d70e3419c6cf3d628d3af6893aaeaee9 Mon Sep 17 00:00:00 2001 From: 10Derozan Date: Tue, 12 Dec 2023 17:06:38 +0800 Subject: [PATCH] fix(module-tools): not execa tsc clean in js project (#5071) --- .changeset/selfish-hairs-invite.md | 6 ++++++ packages/solutions/module-tools/src/builder/clear.ts | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/selfish-hairs-invite.md diff --git a/.changeset/selfish-hairs-invite.md b/.changeset/selfish-hairs-invite.md new file mode 100644 index 000000000000..d33ebbb42cee --- /dev/null +++ b/.changeset/selfish-hairs-invite.md @@ -0,0 +1,6 @@ +--- +'@modern-js/module-tools': patch +--- + +fix(module-tools): not execa tsc clean in js project +fix(module-tools): 不在 js 项目执行 tsc clean diff --git a/packages/solutions/module-tools/src/builder/clear.ts b/packages/solutions/module-tools/src/builder/clear.ts index 2b1e85b9bdab..70057d6560c8 100644 --- a/packages/solutions/module-tools/src/builder/clear.ts +++ b/packages/solutions/module-tools/src/builder/clear.ts @@ -15,7 +15,12 @@ export const clearBuildConfigPaths = async ( } // tsc --build --clean - if (config.buildType === 'bundleless' && config.dts) { + if ( + config.buildType === 'bundleless' && + config.dts && + // keep it same as https://github.com/web-infra-dev/modern.js/blob/main/packages/solutions/module-tools/src/builder/build.ts#L37 + (await fs.pathExists(config.tsconfig)) + ) { const tscBinFile = await getTscBinPath(projectAbsRootPath); const childProgress = execa(tscBinFile, ['--build', '--clean'], { stdio: 'pipe',