feat: tsconfig compilerOptions.paths — aliased bare specifiers join the graph and follow moves

- index/tsconfig: JSONC sanitize (comments, trailing commas), baseUrl +
  star/exact path keys, first candidate only, longest-prefix wins; invalid
  or missing tsconfig silently means no aliases
- resolution pass: '.'-prefixed specifiers resolve relatively as before,
  bare ones go through the alias table and join the importer graph
- planner: remap keeps the alias shape while the moved file stays inside
  the mapped tree (morphological, since destinations do not exist yet),
  exact keys keep meaning only while still resolving to the target;
  otherwise the previous relative rewrite applies unchanged
- resolve_base extracted from resolve_module (shared extension/index
  guessing); MODULE_EXTS is the exact inverse for remapping
- e2e: @utils/str.ts -> @utils/text.ts inside alias, -> ./core/text.ts
  when leaving it, @cfg falls back to ./settings; check passes on aliases
This commit is contained in:
loki5512344 2026-09-15 19:17:06 +02:00
parent f8004e669b
commit b1af375763
Signed by: boba
GPG key ID: 253067914055423B
14 changed files with 400 additions and 5 deletions

View file

@ -147,7 +147,13 @@ fn ts_rewrites(index: &Index, source: &Path, target: &Path) -> Vec<Rewrite> {
.iter()
.filter(|e| e.target.as_deref() == Some(source));
for edge in edges {
let new_text = relative_specifier(&importer, target);
// Aliased imports keep their alias shape when the new location
// still round-trips through the same mapping; everything else
// gets the relative rewrite.
let new_text = index
.aliases
.remap(&edge.record.specifier, target, &index.files)
.unwrap_or_else(|| relative_specifier(&importer, target));
if new_text == edge.record.specifier {
continue; // no-op rewrite, never reaches the plan
}