Skip to content

fix(extract-import-map): resolve tsconfig paths with './' prefix (#214)#239

Open
Ylsssq926 wants to merge 2 commits into
Egonex-AI:mainfrom
Ylsssq926:fix/tsconfig-paths-dotslash
Open

fix(extract-import-map): resolve tsconfig paths with './' prefix (#214)#239
Ylsssq926 wants to merge 2 commits into
Egonex-AI:mainfrom
Ylsssq926:fix/tsconfig-paths-dotslash

Conversation

@Ylsssq926

Copy link
Copy Markdown

Hit this on a Next.js project — all @/ alias imports were missing from the knowledge graph. Traced it to extract-import-map.mjs line 433.

Root cause: When tsconfig uses "@/*": ["./*"] (the default in Next.js / Vite / Nuxt), applyTsAlias produces paths like "./utils". The ternary expression at line 433 skipped posix.join when tsConfigDir was empty (root tsconfig), so the "./" prefix passed through to probeWithExtensions unchanged. Since fileSet stores paths without "./" (e.g. "utils.ts"), the probe never matched.

Fix: Remove the ternary and always run posix.join(tsConfigDir, relativeToConfig). When tsConfigDir is '', posix.join('', './utils') normalizes to 'utils' — matching fileSet. When tsConfigDir is non-empty, behavior is identical to before.

3 lines → 1 line change in the script, plus 3 new test cases:

  • "./*" target (Next.js App Router default)
  • "./src/*" target
  • Multi-target fallback with "./" prefixes

Existing tests still pass — the "src/*" form (without ./) was never affected.

Ylsssq926 added 2 commits June 9, 2026 12:19
…nex-AI#214)

When tsconfig.json uses `"@/*": ["./*"]` (the default in Next.js, Vite,
Nuxt), applyTsAlias produces paths like "./utils". The ternary at line 433
skipped posix.join when tsConfigDir was empty, leaving the "./" prefix
intact. Since fileSet stores paths without "./" (e.g. "utils.ts"), the
probe always missed — dropping all alias-based import edges.

Fix: always run posix.join(tsConfigDir, relativeToConfig). When tsConfigDir
is '', posix.join('', './utils') normalizes to 'utils', matching fileSet.

Added 3 test cases covering "./*", "./src/*", and multi-target fallback
with "./" prefixes.
…base

Latest main already carries the Egonex-AI#214 resolver fix and focused regression coverage.
After rebasing, the original PR tests were duplicated in the tree-sitter
failure block and no longer formed a useful diff. Drop the duplicate block so
the PR branch matches the resolved main behavior.
@Ylsssq926 Ylsssq926 force-pushed the fix/tsconfig-paths-dotslash branch from ef0dac6 to cef7e01 Compare June 9, 2026 05:38
@Ylsssq926

Copy link
Copy Markdown
Author

Rebased this branch onto current main to resolve the conflict. The net PR diff is now empty because current main already includes the #214 import-map fix and focused regression coverage for tsconfig path targets with leading ./ prefixes. Leaving the PR open for maintainer/author decision rather than closing it unilaterally.

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