fix(mod_compiler): add diagnostic snapshots for output directories around clear and compile steps

This commit is contained in:
2026-03-05 14:48:05 +00:00
parent a738716d98
commit 7e8b5c4467
3 changed files with 26 additions and 1 deletions

View File

@@ -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) {