From 7e8b5c4467dc846ef08354e36278fbc7d21956c5 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 5 Mar 2026 14:48:05 +0000 Subject: [PATCH] fix(mod_compiler): add diagnostic snapshots for output directories around clear and compile steps --- changelog.md | 7 +++++++ ts/00_commitinfo_data.ts | 2 +- ts/mod_compiler/classes.tscompiler.ts | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 2afb29f..b3bcf75 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2026-03-05 - 4.1.20 - fix(mod_compiler) +add diagnostic snapshots for output directories around clear and compile steps + +- Introduce diagSnap helper to log entry and directory counts for successful output directories when not in quiet or JSON mode +- Call diagSnap before clearing the destination directory, after clearing, and after compilation to aid debugging of missing or unexpected outputs +- Behavior for emitted files and unpacking is unchanged; this is observational/logging-only instrumentation + ## 2026-03-05 - 4.1.19 - fix(mod_fs) use synchronous rm to avoid XFS metadata corruption when removing directories diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index acd4adf..48b3dd2 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.19', + version: '4.1.20', 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 7d2c613..552e36d 100644 --- a/ts/mod_compiler/classes.tscompiler.ts +++ b/ts/mod_compiler/classes.tscompiler.ts @@ -338,13 +338,30 @@ export class TsCompiler { // Get destination directory as absolute path const destDir = smartpath.transform.toAbsolute(destPath, this.cwd) as string; + // Diagnostic helper + const diagSnap = (label: string) => { + if (!isQuiet && !isJson) { + for (const prevDir of successfulOutputDirs) { + try { + const entries = fs.readdirSync(prevDir); + const dirs = entries.filter(e => { try { return fs.statSync(prevDir + '/' + e).isDirectory(); } catch { return false; } }); + console.log(` ๐Ÿ“‹ [${label}] ${prevDir.replace(this.cwd + '/', '')}: ${entries.length} entries, ${dirs.length} dirs`); + } catch { + console.log(` ๐Ÿ“‹ [${label}] ${prevDir.replace(this.cwd + '/', '')}: MISSING!`); + } + } + } + }; + // Clear the destination directory before compilation if it exists + diagSnap('pre-clear'); if (await FsHelpers.directoryExists(destDir)) { if (!isQuiet && !isJson) { console.log(`๐Ÿงน Clearing output directory: ${destPath}`); } await FsHelpers.removeDirectory(destDir); } + diagSnap('post-clear'); // Update compiler options with the output directory const options: CompilerOptions = { @@ -365,6 +382,7 @@ export class TsCompiler { const result = await this.compileFiles(absoluteFiles, options, taskInfo); emittedFiles.push(...result.emittedFiles); errorSummaries.push(result.errorSummary); + diagSnap('post-compile'); // Perform unpack if compilation succeeded if (result.errorSummary.totalErrors === 0) {