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:
parent
f8004e669b
commit
b1af375763
14 changed files with 400 additions and 5 deletions
1
tests/typescript/aliased/package.json
Normal file
1
tests/typescript/aliased/package.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ "name": "aliased-fixture" }
|
||||
7
tests/typescript/aliased/src/app.ts
Normal file
7
tests/typescript/aliased/src/app.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { shout } from "@utils/str";
|
||||
import cfg from "@cfg";
|
||||
import { log } from "./utils/log";
|
||||
|
||||
export function go(): string {
|
||||
return shout(cfg) + log();
|
||||
}
|
||||
1
tests/typescript/aliased/src/config.ts
Normal file
1
tests/typescript/aliased/src/config.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default "cfg";
|
||||
3
tests/typescript/aliased/src/utils/log.ts
Normal file
3
tests/typescript/aliased/src/utils/log.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export function log(): string {
|
||||
return "";
|
||||
}
|
||||
3
tests/typescript/aliased/src/utils/str.ts
Normal file
3
tests/typescript/aliased/src/utils/str.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export function shout(s: string): string {
|
||||
return s.toUpperCase();
|
||||
}
|
||||
10
tests/typescript/aliased/tsconfig.json
Normal file
10
tests/typescript/aliased/tsconfig.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
// JSONC on purpose: comments and trailing commas must not break loading
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./src",
|
||||
"paths": {
|
||||
"@utils/*": ["utils/*"],
|
||||
"@cfg": ["config.ts"],
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue