Repository navigation
Conversation
…nalysis analyze-javascript-application reported ./dep.js as not-found whenever only dep.ts existed, so TypeScript NodeNext source trees lost almost all internal import edges. The reference-source importer gained exactly this substitution in morluto#815; the application resolver did not. Extract the rule into a shared helper (TypeScript callers only, emitted .js/.mjs/.cjs/.jsx names substitute .ts/.tsx/.d.ts, .mts/.d.mts, .cts/.d.cts, .tsx/.d.ts, explicit filenames only, present runtime files always win) and apply it to both resolvers. Fixes morluto#1811.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11a31e0ec7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ? [".tsx", ".d.ts"] | ||
| : []; | ||
| if (suffixes.length === 0) return []; | ||
| const stem = candidate.slice(0, -posix.extname(candidate).length); |
There was a problem hiding this comment.
Retain directories when substituting emitted dotfiles
For a nested TypeScript module importing the valid emitted dotfile ./.js, the candidate is src/.js, but posix.extname("src/.js") is empty, so slice(0, -0) discards the entire candidate and generates root-level .ts/.tsx/.d.ts candidates instead of src/.ts and its peers. The new application lookup can therefore leave this NodeNext edge unresolved or, when an unrelated root .ts exists in the same container, record an edge to the wrong file; strip the already-detected emitted suffix directly so the directory is preserved.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
…le names A candidate that is itself a dotfile name, such as src/.js, made posix.extname return an empty extension, so the stem computation sliced the whole candidate away and generated root-level source candidates. Match each emitted suffix and strip it by matched length from one table, which keeps the substitution within the candidate's directory and gives the emitted and source suffixes a single shared source of truth.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0bee7b632
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| resolveFileCandidates(input, fileCandidates(candidate)) ?? | ||
| resolveFileCandidates(input, [ | ||
| ...fileCandidates(candidate), | ||
| ...typescriptEmittedSourceCandidates(input.sourcePath, candidate), |
There was a problem hiding this comment.
Restrict emitted-source candidates to module lookups
When analyzing a .ts file that creates new Worker("./worker.js") while only worker.ts is inventoried, the url-reference path reaches resolveCandidate and this unconditional candidate makes the worker look resolved to TypeScript even though URL loading does not perform NodeNext extension substitution. That fabricates a loads edge rather than preserving the missing runtime URL, so gate this fallback to module-specifier resolution (the HTML branch is already kept exact).
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
…sclosure With NodeNext emitted-extension resolution, import "./util.js" inside util.ts resolves back to the importing module itself, so it is disclosed through the same self-import omission instead of a not-found edge.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d382550a31
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| resolveFileCandidates(input, fileCandidates(candidate)) ?? | ||
| resolveFileCandidates(input, [ | ||
| ...fileCandidates(candidate), | ||
| ...typescriptEmittedSourceCandidates(input.sourcePath, candidate), |
There was a problem hiding this comment.
Do not substitute TypeScript sources for file-URL imports
When a .ts module imports file:///assets/dep.js and only assets/dep.ts is inventoried, contextualCandidate first converts that URL to assets/dep.js, after which this unconditional helper call resolves it to the TypeScript file. NodeNext skips absolute-URI specifiers and Node executes the URL's exact .js resource, so the graph now fabricates a resolved internal import; preserve whether the candidate came from fileUrlPath and bypass emitted-name substitution in that case.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
…ule specifiers
Address review: NodeNext emitted-name substitution models TypeScript
module resolution, but the helper ran for every resolveCandidate lookup.
A url-reference such as new Worker("./worker.js") and an absolute
file:// module import load the exact resource named; resolving either
to a TypeScript counterpart fabricated a loads or module edge that
NodeNext never performs. The substitution now applies only to
module-specifier lookups whose declaration carries no scheme and is not
a file URL.
|
Superseded by 1dfb933e4 and f8513a42d, now on main. The shared emitted-source helper and self-import behavior are retained, with public CLI coverage for multiple distinct source counterparts, runtime-file precedence, and Electron resource-path boundaries. Package/URL targets remain exact. Issue #1811 is closed as fixed; #1818 remains open for its distinct proposal. |
Summary
analyze-javascript-applicationreported./dep.jsasnot-foundwhenever onlydep.tsexisted on disk, so TypeScript NodeNext source trees lost almost all internal import edges and feature traces stopped at the first import. The reference-source importer gained exactly this substitution through #755/#815; the application resolver (resolveCandidate) did not. This PR applies the same rule there, extracted into one shared helper used by both resolvers.Problem and expected behavior
In a TypeScript ESM/NodeNext source tree, relative imports name the emitted file:
import { dep } from "./dep.js"with onlydep.tspresent resolves undertsc --module NodeNext --moduleResolution NodeNext, as do./x.mjs->x.mts,./x.cjs->x.cts,./B.js->B.tsx, and the declaration counterparts (.d.ts,.d.mts,.d.cts). Application analysis reported every one asnot-foundwith nounknownsentry, silently. This is #1811; the resolver gap was also flagged during the #1130 merge review.Expected: these specifiers resolve to their TypeScript source counterparts, and every previously working shape keeps resolving.
Change and scope
src/application/TypeScriptEmittedSourceCandidates.ts: for TypeScript-family callers (.ts,.tsx,.mts,.cts, including declaration callers, matching the tsc-verified behavior retained in fix(reference): resolve emitted extensions to TypeScript source #755), a candidate ending in an emitted extension substitutes its source counterparts (.js->.ts/.tsx/.d.ts,.mjs->.mts/.d.mts,.cjs->.cts/.d.cts,.jsx->.tsx/.d.ts). Explicit filenames only: no directory or index resolution. JavaScript callers get no fallback.resolveCandidateappends these after the existing runtime candidates, so a present runtime file always wins and every other candidate order is unchanged.ReferenceSourceImportEntries.resolveInternalSpecifiernow calls the same helper instead of its inline copy. The logic is token-identical to the merged fix: integrate 24 reviewed browser/native/semantics corrections #815 rule (same caller gate, same suffix lists, same stem computation); its eight behavior tests are unchanged and pass.Contract and boundary impact
not applicable: resolver candidate list extension only; no schema, contract, or provider change. Module edges that previously carried
resolution_status: "not-found"now carry resolved paths, which is the issue's requested outcome.Evidence and regression coverage
JavaScriptArtifactPathResolution.test.ts: five emitted-name cases (.js->.ts,./ui/Button.js->.tsx,.mjs->.mts,.cjs->.cts,.js->.tsx), three declaration-counterpart cases, plus four controls that already passed and must keep passing (runtime file wins, JavaScript-caller negative, no index substitution, extensionless resolution). 78/78 pass.referenceSourceImport) is untouched by behavior: its failures on Windows are the known symlink-EPERM environment artifacts, identical count on a clean main worktree.module_link_kind: "import"edges resolve -./dep.js->src/dep.ts,./ui/Button.js->src/ui/Button.tsx,./cfg.mjs->src/cfg.mts,./legacy.cjs->src/legacy.cts,./util->src/util.ts- and the graph reports zero unknown nodes.check:fastpasses; jscpd stays under its budget (the shared helper replaces the inline copy rather than adding duplication).