feat: tsconfig path alias resolution for import tracking#12
Merged
Conversation
- Add get-tsconfig dependency for parsing tsconfig.json paths/baseUrl
- New src/resolve.ts module: ImportResolver with auto-detected tsconfig,
per-directory caching, and explicit paths-pattern matching
- Remove startsWith('.') filters from ast.ts — all imports now extracted,
resolver decides what's local vs external in core.ts
- Fix handleExportStatement to skip ALL re-exports (not just relative)
- Fix latent path mismatch bug: canonicalizePath() now normalizes all
SymbolRef.file values consistently (strips extensions + /index)
- Backward-compat: getRecentFootprints() canonicalizes stored paths on read
- Add --tsconfig CLI option and tsconfig-path action input
- 56 tests (19 new resolver + 5 new ast + 32 existing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/resolve.tsmodule:ImportResolverthat auto-detects the nearesttsconfig.json, parsescompilerOptions.paths, and resolves aliased imports (e.g.,@/lib/logger→src/lib/logger). Caches tsconfig lookups per directory for monorepo support.startsWith('.')filters fromast.ts: All imports are now extracted by the parser. The resolver incore.tsdecides what's local vs external — external packages returnnulland are skipped.handleExportStatementnow skips ALL re-exports (not just relative ones).export { foo } from '@/utils'was previously added as a local symbol — now correctly treated as an import reference.canonicalizePath()normalizes allSymbolRef.filevalues consistently (strips.ts/.tsx/.js/.jsxextensions and/indexsuffixes). Previously,symbols_addedstoredsrc/helpers.tswhilesymbols_referencedstoredsrc/helpers— these never matched.getRecentFootprints()canonicalizes stored paths on read, so old footprints (with extensions) match new canonical paths. Self-resolves as old entries expire.--tsconfigCLI option andtsconfig-pathaction input for explicit override (auto-detected by default).get-tsconfig(zero-dep, 7KB, CJS-compatible)Test plan
@/path aliases