From fba2cba8e8a2e86eef5a33206e4752487a9d3da2 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 5 Mar 2026 14:51:14 +0000 Subject: [PATCH] fix(compiler): log emitted files written outside expected destination directory for diagnostics --- changelog.md | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/mod_compiler/classes.tscompiler.ts | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index b3bcf75..762d4cf 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-03-05 - 4.1.21 - fix(compiler) +log emitted files written outside expected destination directory for diagnostics + +- Adds diagnostic logging for emitted files that are not under the configured destDir, listing up to 20 example paths and reporting the remaining count. +- Logging is conditional: only when not in quiet mode and not emitting JSON. +- Diagnostic runs after compilation (post-compile) and before unpacking of outputs; paths are trimmed using the process cwd for readability. + ## 2026-03-05 - 4.1.20 - fix(mod_compiler) add diagnostic snapshots for output directories around clear and compile steps diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 48b3dd2..c649f09 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tsbuild', - version: '4.1.20', + version: '4.1.21', description: 'A tool for compiling TypeScript files using the latest nightly features, offering flexible APIs and a CLI for streamlined development.' } diff --git a/ts/mod_compiler/classes.tscompiler.ts b/ts/mod_compiler/classes.tscompiler.ts index 552e36d..ff66f84 100644 --- a/ts/mod_compiler/classes.tscompiler.ts +++ b/ts/mod_compiler/classes.tscompiler.ts @@ -384,6 +384,20 @@ export class TsCompiler { errorSummaries.push(result.errorSummary); diagSnap('post-compile'); + // Diagnostic: log emitted files that went to unexpected directories + if (!isQuiet && !isJson && result.emittedFiles.length > 0) { + const unexpectedFiles = result.emittedFiles.filter(f => !f.startsWith(destDir + '/') && !f.startsWith(destDir + '\\')); + if (unexpectedFiles.length > 0) { + console.log(` ⚠️ [diag] ${unexpectedFiles.length} files emitted OUTSIDE ${destPath}:`); + for (const f of unexpectedFiles.slice(0, 20)) { + console.log(` ${f.replace(this.cwd + '/', '')}`); + } + if (unexpectedFiles.length > 20) { + console.log(` ... and ${unexpectedFiles.length - 20} more`); + } + } + } + // Perform unpack if compilation succeeded if (result.errorSummary.totalErrors === 0) { await performUnpack(pattern, destDir, this.cwd);