From 8f63b0038d2e555d39ffbdc53b33d66b94068d26 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 9 Sep 2021 02:50:50 +0800 Subject: [PATCH] fix(tsbb): Fix empty out dir issue. --- packages/tsbb/src/utils/compile.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/tsbb/src/utils/compile.ts b/packages/tsbb/src/utils/compile.ts index 18b6c6cd..0203edd9 100644 --- a/packages/tsbb/src/utils/compile.ts +++ b/packages/tsbb/src/utils/compile.ts @@ -19,7 +19,12 @@ export async function compile( cjs = path.relative(ts.sys.getCurrentDirectory(), cjs); return new Promise(async (resolve, reject) => { try { - await FS.remove(outDir); + if (tsOptions.outDir || cjs) { + await FS.remove(outDir); + } + if (esm) { + await FS.remove(path.resolve(process.cwd(), esm)); + } const dirToFiles = await recursiveReaddirFiles(path.dirname(entry), { exclude: /(tsconfig.json|.d.ts|.(test|spec).(ts|tsx|js|jsx))$/, });