fix(mod_compiler): add diagnostic logging of output directory states after compilation and after import-path rewriting to aid debugging
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user