diff --git a/changelog.md b/changelog.md index a18d1f3..ee1758b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2026-03-05 - 4.1.18 - fix(mod_compiler) +add diagnostic logging of output directory states after compilation and after import-path rewriting to aid debugging + +- Imported fs to allow reading output directories for diagnostics +- Logs entries and directory counts for each successful output directory both pre- and post-import-path-rewrite +- Diagnostics are gated by !isQuiet && !isJson and are read-only (no behavior change) +- Tags used: 'diag' (post-compilation) and 'diag-post-rewrite' (after rewriting) to help identify missing or unexpected output folders + ## 2026-03-05 - 4.1.17 - fix(tsunpacker) use synchronous fs operations in tsunpacker to avoid readdir race conditions diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index dfbe6ff..16cf670 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.17', + version: '4.1.18', 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 9ef52de..7d2c613 100644 --- a/ts/mod_compiler/classes.tscompiler.ts +++ b/ts/mod_compiler/classes.tscompiler.ts @@ -1,5 +1,6 @@ import type { CompilerOptions, Diagnostic, Program } from 'typescript'; import typescript from 'typescript'; +import * as fs from 'fs'; import * as smartdelay from '@push.rocks/smartdelay'; import * as smartpromise from '@push.rocks/smartpromise'; import * as smartpath from '@push.rocks/smartpath'; @@ -371,6 +372,21 @@ export class TsCompiler { successfulOutputDirs.push(destDir); } + // Diagnostic: log all output directory states after each compilation + 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(` 📋 [diag] ${prevDir.replace(this.cwd + '/', '')}: ${entries.length} entries, ${dirs.length} dirs`); + } catch { + console.log(` 📋 [diag] ${prevDir.replace(this.cwd + '/', '')}: MISSING!`); + } + } + } + } // Rewrite import paths in all output directories to handle cross-module references @@ -385,6 +401,21 @@ export class TsCompiler { if (totalRewritten > 0 && !isQuiet && !isJson) { console.log(` 🔄 Rewrote import paths in ${totalRewritten} file${totalRewritten !== 1 ? 's' : ''}`); } + + // Diagnostic: log output directory states after path rewriting + if (!isQuiet && !isJson) { + for (const dir of successfulOutputDirs) { + try { + const entries = fs.readdirSync(dir); + const dirs = entries.filter(e => { + try { return fs.statSync(dir + '/' + e).isDirectory(); } catch { return false; } + }); + console.log(` 📋 [diag-post-rewrite] ${dir.replace(this.cwd + '/', '')}: ${entries.length} entries, ${dirs.length} dirs`); + } catch { + console.log(` 📋 [diag-post-rewrite] ${dir.replace(this.cwd + '/', '')}: MISSING!`); + } + } + } } // Merge all error summaries