Skip to content

feat: tsconfig path alias resolution for import tracking#12

Merged
TonyStef merged 1 commit intomainfrom
feat/tsconfig-path-resolution
Mar 24, 2026
Merged

feat: tsconfig path alias resolution for import tracking#12
TonyStef merged 1 commit intomainfrom
feat/tsconfig-path-resolution

Conversation

@TonyStef
Copy link
Copy Markdown
Owner

Summary

  • New src/resolve.ts module: ImportResolver that auto-detects the nearest tsconfig.json, parses compilerOptions.paths, and resolves aliased imports (e.g., @/lib/loggersrc/lib/logger). Caches tsconfig lookups per directory for monorepo support.
  • Removed startsWith('.') filters from ast.ts: All imports are now extracted by the parser. The resolver in core.ts decides what's local vs external — external packages return null and are skipped.
  • Fixed re-export handling: handleExportStatement now 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.
  • Fixed latent path mismatch bug: canonicalizePath() normalizes all SymbolRef.file values consistently (strips .ts/.tsx/.js/.jsx extensions and /index suffixes). Previously, symbols_added stored src/helpers.ts while symbols_referenced stored src/helpers — these never matched.
  • Backward compatibility: getRecentFootprints() canonicalizes stored paths on read, so old footprints (with extensions) match new canonical paths. Self-resolves as old entries expire.
  • New --tsconfig CLI option and tsconfig-path action input for explicit override (auto-detected by default).
  • New dependency: get-tsconfig (zero-dep, 7KB, CJS-compatible)

Test plan

  • 56/56 tests pass (19 new resolver + 5 new AST + 32 existing)
  • Typecheck clean
  • Biome lint clean
  • ncc bundle builds successfully (3786kB, up from 3756kB)
  • Test on a real repo with @/ path aliases

- 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)
@TonyStef TonyStef merged commit cd740cd into main Mar 24, 2026
1 check passed
@TonyStef TonyStef deleted the feat/tsconfig-path-resolution branch March 24, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant