From 35095a0219bd54c3b64a3cfcbb1758d6030d25ce Mon Sep 17 00:00:00 2001 From: Pan Qiancheng <905739777@qq.com> Date: Sat, 20 Dec 2025 14:42:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=9D=9Ets?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=AE=E6=94=B9=E6=97=B6=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=BA=90=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=AF=AF=E5=88=A0=E9=99=A4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/server/watch.js | 4 ++-- src/server/watch.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/server/watch.js b/lib/server/watch.js index c801260..d0dae67 100644 --- a/lib/server/watch.js +++ b/lib/server/watch.js @@ -280,11 +280,12 @@ const createCompiler = async (projectPath, options, projectReferences, treatFile }; const compileTask = async (task) => { const { filePath, changeType } = task; + const modulePath = path_1.default.resolve(filePath); // 判断文件类型 if (!filePath.endsWith(".ts")) { // 处理非TypeScript文件 (如JSON文件) if (filePath.endsWith(".json")) { - const targetPath = filePath.replace(path_1.default.join(projectPath, "src"), path_1.default.join(projectPath, "lib")); + const targetPath = modulePath.replace(path_1.default.join(projectPath, "src"), path_1.default.join(projectPath, "lib")); try { if (changeType === "remove") { if (fs_1.default.existsSync(targetPath)) { @@ -331,7 +332,6 @@ const createCompiler = async (projectPath, options, projectReferences, treatFile // 处理TypeScript文件 console.clear(); console.warn(`File ${filePath} has been ${changeType}d`); - const modulePath = path_1.default.resolve(filePath); const libPath = modulePath .replace(path_1.default.join(projectPath, "src"), path_1.default.join(projectPath, "lib")) .replace(/\.ts$/, ".js"); diff --git a/src/server/watch.ts b/src/server/watch.ts index 61ad4a0..dfed001 100644 --- a/src/server/watch.ts +++ b/src/server/watch.ts @@ -477,11 +477,12 @@ const createCompiler = async ( const compileTask = async (task: CompileTask): Promise => { const { filePath, changeType } = task; + const modulePath = pathLib.resolve(filePath); // 判断文件类型 if (!filePath.endsWith(".ts")) { // 处理非TypeScript文件 (如JSON文件) if (filePath.endsWith(".json")) { - const targetPath = filePath.replace( + const targetPath = modulePath.replace( pathLib.join(projectPath, "src"), pathLib.join(projectPath, "lib") ); @@ -533,7 +534,6 @@ const createCompiler = async ( console.clear(); console.warn(`File ${filePath} has been ${changeType}d`); - const modulePath = pathLib.resolve(filePath); const libPath = modulePath .replace(pathLib.join(projectPath, "src"), pathLib.join(projectPath, "lib")) .replace(/\.ts$/, ".js");