fix(TsPathRewriter): auto-detect all ts_* folders in project for cross-module import rewriting

Previously only mapped folders from the current compilation glob patterns.
Now scans project directory for all ts_* folders to ensure imports like
'../ts_shared/' are rewritten to '../dist_ts_shared/' even when compiling
only the main ts/ folder.
This commit is contained in:
2026-01-12 17:53:06 +00:00
parent 1e40bd5882
commit c8a1582ec4
2 changed files with 35 additions and 1 deletions

View File

@@ -373,8 +373,9 @@ export class TsCompiler {
// Rewrite import paths in all output directories to handle cross-module references
// This must happen after ALL compilations so all destination folders exist
// Use fromProjectDirectory to detect ALL ts_* folders, not just the ones being compiled
if (successfulOutputDirs.length > 0) {
const rewriter = TsPathRewriter.fromGlobPatterns(globPatterns);
const rewriter = await TsPathRewriter.fromProjectDirectory(this.cwd);
let totalRewritten = 0;
for (const outputDir of successfulOutputDirs) {
totalRewritten += await rewriter.rewriteDirectory(outputDir);