[PR #1818] [CLOSED] fix(javascript): resolve NodeNext emitted extensions to TypeScript sources #4835

Closed
opened 2026-10-31 00:55:33 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1818
Author: @charan-rathore
Created: 10/11/2026
Status: ❌ Closed

Base: main ← Head: fix/javascript-nodenext-emitted-extension-resolution


📝 Commits (5)

  • c0db35d fix(javascript): resolve NodeNext emitted extensions to TypeScript sources
  • 94d9221 fix(javascript): probe emitted-extension counterparts for module specifiers only
  • bd45bbd fix(javascript): exclude loadURL references from emitted-extension probing
  • 9989f01 fix(javascript): gate emitted-extension probing on a positive module origin
  • 366e9d4 fix(javascript): probe package-selected targets for TypeScript counterparts

📊 Changes

7 files changed (+275 additions, -1 deletions)

View changed files

📝 src/application/javascript/ElectronBoundaryAnalysis.ts (+5 -0)
📝 src/application/javascript/ElectronBoundaryGraphNative.ts (+1 -0)
📝 src/application/javascript/JavaScriptArtifactGraphContext.ts (+4 -0)
📝 src/application/javascript/JavaScriptArtifactGraphFindings.ts (+8 -0)
📝 src/application/javascript/JavaScriptArtifactPathResolution.test.ts (+197 -0)
📝 src/application/javascript/JavaScriptArtifactPathResolution.ts (+59 -1)
📝 src/application/javascript/JavaScriptModuleRelationships.ts (+1 -0)

📄 Description

Fixes #1811.

Problem

A TypeScript source compiled with NodeNext imports the emitted runtime name - import "./dep.js" when only dep.ts exists. The application artifact path resolver tried the literal candidate, extension appends, and directory packages only, so these imports reported not-found even though the TypeScript source was present in the artifact. Extensionless relative imports already worked; the emitted-extension form did not.

Fix

resolveCandidate in JavaScriptArtifactPathResolution now also probes the emitted-extension source counterparts when the importing artifact is TypeScript (.ts/.tsx/.mts/.cts):

  • ./dep.js also probes dep.ts, dep.tsx, dep.d.ts
  • ./cfg.mjs also probes cfg.mts, cfg.d.mts
  • ./legacy.cjs also probes legacy.cts, legacy.d.cts
  • .jsx also probes .tsx, .d.ts

This mirrors the emitted-extension mapping that ReferenceSourceImportEntries already applies to reference imports (#755). Ordering and scope follow that precedent: the plain runtime candidates are checked first so a present emitted file keeps winning, counterparts cover explicit filenames only (not directory or index resolution), and JavaScript importers keep the previous behavior.

Tests

Added a NodeNext emitted-extension path resolution block to JavaScriptArtifactPathResolution.test.ts:

  • .js/.mjs/.cjs specifiers from a TypeScript source resolve to .ts/.tsx/.mts/.cts (4 cases)
  • a present emitted runtime file wins over its TypeScript counterpart
  • a JavaScript importer does not get TypeScript counterparts (stays not-found)

Verification on Node 22.23.3 (engines allow ^22.19.0): the 4 new cases fail without the fix and the full file passes with it (72/72). Scoped tsc --noEmit on the changed module and oxlint on both changed files are clean (0 errors). I could not run the repo-wide check:fast gate to completion - the monorepo typecheck exceeds the memory of my environment - so that gate is not claimed here.

Notes

  • No behavior change for directory/index resolution or for non-TypeScript importers.
  • verify:test-discovery passes for the updated test file.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1818 **Author:** [@charan-rathore](https://github.com/charan-rathore) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/javascript-nodenext-emitted-extension-resolution` --- ### 📝 Commits (5) - [`c0db35d`](https://github.com/morluto/rea/commit/c0db35dda51eecd4521f9bf4861d950a0725f4db) fix(javascript): resolve NodeNext emitted extensions to TypeScript sources - [`94d9221`](https://github.com/morluto/rea/commit/94d9221194ed462bb9141e0fd53a9f5233c93a7d) fix(javascript): probe emitted-extension counterparts for module specifiers only - [`bd45bbd`](https://github.com/morluto/rea/commit/bd45bbd5150097eae7bb4fbe20e124db546f0526) fix(javascript): exclude loadURL references from emitted-extension probing - [`9989f01`](https://github.com/morluto/rea/commit/9989f016f4bd5ca1943875cec35590b733f1feb6) fix(javascript): gate emitted-extension probing on a positive module origin - [`366e9d4`](https://github.com/morluto/rea/commit/366e9d4df8a3e8da2dd19ad38844e93bb34099b0) fix(javascript): probe package-selected targets for TypeScript counterparts ### 📊 Changes **7 files changed** (+275 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/application/javascript/ElectronBoundaryAnalysis.ts` (+5 -0) 📝 `src/application/javascript/ElectronBoundaryGraphNative.ts` (+1 -0) 📝 `src/application/javascript/JavaScriptArtifactGraphContext.ts` (+4 -0) 📝 `src/application/javascript/JavaScriptArtifactGraphFindings.ts` (+8 -0) 📝 `src/application/javascript/JavaScriptArtifactPathResolution.test.ts` (+197 -0) 📝 `src/application/javascript/JavaScriptArtifactPathResolution.ts` (+59 -1) 📝 `src/application/javascript/JavaScriptModuleRelationships.ts` (+1 -0) </details> ### 📄 Description Fixes #1811. ## Problem A TypeScript source compiled with NodeNext imports the emitted runtime name - `import "./dep.js"` when only `dep.ts` exists. The application artifact path resolver tried the literal candidate, extension appends, and directory packages only, so these imports reported `not-found` even though the TypeScript source was present in the artifact. Extensionless relative imports already worked; the emitted-extension form did not. ## Fix `resolveCandidate` in `JavaScriptArtifactPathResolution` now also probes the emitted-extension source counterparts when the importing artifact is TypeScript (`.ts`/`.tsx`/`.mts`/`.cts`): - `./dep.js` also probes `dep.ts`, `dep.tsx`, `dep.d.ts` - `./cfg.mjs` also probes `cfg.mts`, `cfg.d.mts` - `./legacy.cjs` also probes `legacy.cts`, `legacy.d.cts` - `.jsx` also probes `.tsx`, `.d.ts` This mirrors the emitted-extension mapping that `ReferenceSourceImportEntries` already applies to reference imports (#755). Ordering and scope follow that precedent: the plain runtime candidates are checked first so a present emitted file keeps winning, counterparts cover explicit filenames only (not directory or index resolution), and JavaScript importers keep the previous behavior. ## Tests Added a `NodeNext emitted-extension path resolution` block to `JavaScriptArtifactPathResolution.test.ts`: - `.js`/`.mjs`/`.cjs` specifiers from a TypeScript source resolve to `.ts`/`.tsx`/`.mts`/`.cts` (4 cases) - a present emitted runtime file wins over its TypeScript counterpart - a JavaScript importer does not get TypeScript counterparts (stays `not-found`) Verification on Node 22.23.3 (engines allow ^22.19.0): the 4 new cases fail without the fix and the full file passes with it (72/72). Scoped `tsc --noEmit` on the changed module and oxlint on both changed files are clean (0 errors). I could not run the repo-wide `check:fast` gate to completion - the monorepo typecheck exceeds the memory of my environment - so that gate is not claimed here. ## Notes - No behavior change for directory/index resolution or for non-TypeScript importers. - `verify:test-discovery` passes for the updated test file. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:55:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4835
No description provided.