fix: apply ESM .js extension fallback to tsconfig path alias resolution#1530
Conversation
Path alias imports (e.g. `@/utils.js` via tsconfig paths) now correctly strip JS-family extensions and retry with TS equivalents when the literal .js file does not exist. This applies the same stripJsExtension fallback already used for relative imports to the alias resolution branch. Fixes abhigyanpatwari#1528
|
@chouzz is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
✨ PR AutofixFound fixable formatting / unused-import issues across 19 changed lines. Comment |
CI Report✅ All checks passed Pipeline Status
Test Results
✅ All 8992 tests passed 1 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
|
/autofix |
|
✅ Applied autofix and pushed a commit. (apply run) |
|
Claude finished @magyargergo's task in 4m 53s —— View job PR #1530 Production-Readiness ReviewTasks
Review bar for this PRThis PR touches Current PR state
The previous CI run (referenced in the CI report comment, run_id 25783775950) showed "Some checks failed" — attributable to the formatting issues that Branch hygiene assessmentVerdict: merge-from-main commit present but harmless and merge-safe. The PR-only net diff is exactly 2 files. Confirmed by inspecting Understanding of the changeBefore this PR:
After this PR: The alias branch ( Why it matters for graph correctness: An import FindingsFinding 1 — CI incomplete, cannot confirm required checks pass
Finding 2 — No alias-specific tests for
|
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Claude finished @magyargergo's task in 4m 56s —— View job PR #1530 Adversarial Production-Readiness ReviewTasks
Review bar for this PR
Current PR state
All 6 required CI runs are completed/success on the final head Branch hygiene assessmentVerdict: merge-from-main commit present but harmless and merge-safe. The PR has 20 commits, the majority of which are
A squash or regular merge produces a 2-file net PR diff. No unrelated file churn from the PR's own commits. Understanding of the changePre-fix flow for
Post-fix flow:
The 7-line block ( FindingsFinding 1 — Test helper uses
|
| Check | Conclusion |
|---|---|
| Docker Build & Push | ✅ success |
| Gitleaks | ✅ success |
| PR Autofix | ✅ success |
| Dependency Review | ✅ success |
| CodeQL | ✅ success |
| CI (tests/typecheck/lint/e2e) | ✅ success |
The prior review's CI-blocking concern is resolved. This is not a stale result — runs were created at 2026-05-14T12:12:43Z against the final head.
Hidden Unicode / hygiene
✅ Clean. Grep for bidi controls (U+202A–U+202E, U+2066–U+2069) and zero-width characters (U+200B, U+200C, U+200D, U+FEFF) found zero matches in both changed files. No non-ASCII characters found in executable paths, regexes, or string literals.
Final verdict
production-ready with minor follow-ups
The implementation is correct and well-scoped: the 7-line alias-branch ESM fallback is placed exactly right (after direct resolution, before suffix fallback), literal .js file precedence is preserved, suffix matching is not regressed, and the relative import path is unchanged. All CI checks are green on the final head dec773e1. Branch hygiene is clean — the net PR diff is exactly 2 files. The only finding is a minor type mismatch in the test helper ([string, string][] where Map<string, string> is expected), which is runtime-safe and not caught by CI because test files are excluded from the CI typecheck invocation. A maintainer may merge as-is and track the type-safe test helper and test-tsconfig CI coverage as follow-up tasks, or apply the fix before merge.
Matches TsconfigPaths.aliases from language-config. CI cannot run tsc -p tsconfig.test.json yet: the project has hundreds of pre-existing errors under test/ (fixtures + unit/integration); enable that step after backlog cleanup. Co-authored-by: Cursor <cursoragent@cursor.com>
…on (abhigyanpatwari#1530) * fix: apply ESM .js extension fallback to tsconfig path alias resolution Path alias imports (e.g. `@/utils.js` via tsconfig paths) now correctly strip JS-family extensions and retry with TS equivalents when the literal .js file does not exist. This applies the same stripJsExtension fallback already used for relative imports to the alias resolution branch. Fixes abhigyanpatwari#1528 * chore(autofix): apply prettier + eslint fixes via /autofix command * test(esm): cover .mjs/.cjs path-alias extension resolution Co-authored-by: Cursor <cursoragent@cursor.com> * test(esm): use Map for path aliases in resolveWithAlias helper Matches TsconfigPaths.aliases from language-config. CI cannot run tsc -p tsconfig.test.json yet: the project has hundreds of pre-existing errors under test/ (fixtures + unit/integration); enable that step after backlog cleanup. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Gergő Magyar <gergomagyar@icloud.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Fixes #1528 — Path alias imports with
.jsextensions now correctly resolve to.tssource files.Problem
import { foo } from '@/utils.js'(via tsconfig path aliases) failed to resolve because the alias branch inresolveImportPathcalledtryResolveWithExtensionswithout thestripJsExtensionretry logic that was already applied to relative imports in #1525.Fix
Apply the same
stripJsExtension+tryResolveWithExtensionsfallback in the tsconfig alias branch after the initial direct resolution fails. Also removed the now-outdated NOTE comment about this being a known limitation.Testing
.js→.ts, alias +.jsx→.tsx, real.jswins over fallback, alias with baseUrl prefix, and null for missing files.tsc --noEmitpasses.