Repository navigation
fix(core): resolve a .jsx specifier to its .tsx or .ts source - #874
Merged
Brooooooklyn merged 2 commits intoOct 22, 2026
Merged
Conversation
Outside node_modules, `./x.jsx` now tries `x.tsx`, `x.ts`, `x.jsx` and `x.js`, as tsc and tsx resolve it. Before, `import './App.jsx'` with only `App.tsx` on disk failed with ERR_MODULE_NOT_FOUND.
β¦ack comment The node_modules fallback comment said the two orders only disagree on a source-first extension. A project's .jsx import into a package can now land on its .js, which the package order would not find; tsc and tsx resolve it the same way, so the result is kept and the comment says so. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with π. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Brooooooklyn
added a commit
that referenced
this pull request
Oct 22, 2026
β¦names (#881) Closes #878 ### Problem Since #840 every resolve outside `node_modules` tried TypeScript first. That is right for an import from a TypeScript file, as tsc and tsx resolve it. But it also hit the entry point and imports from JavaScript files, where Node.js and tsx run the `.js` file that was named. ``` before after node tsx oxnode ./main.js main.ts main.js main.js main.js importer.js β ./dep.js dep.ts dep.js dep.js dep.js main.ts β ./dep.js dep.ts dep.ts β dep.ts (#840, unchanged) ``` ### Fix There's a new order, `ExtensionOrder::Named`: the file the specifier names first, then TypeScript. `extension_order()` picks the order from the importer: ``` importer in node_modules βββββββββββββββΊ Package (unchanged) importer .ts .tsx .mts .cts .jsx βββββββΊ Source (unchanged, #840 / #874) anything else ββββββββββββββββββββββββββΊ Named (new) entry point Β· --import preload Β· .js .mjs .cjs Β· [eval1] Β· the importer's directory parent ``` - `Named` aliases: `.js β .js .ts .tsx .jsx`, `.jsx β .jsx .tsx .ts .js`, `.mjs β .mjs .mts`, `.cjs β .cjs .cts`. A missing `.js` still finds its `.ts`, as tsx does. - Extensionless `./dep` stays TypeScript first, as tsx resolves it. - `.jsx` importers stay TypeScript first: tsx counts `.jsx` as TypeScript (`/\.([cm]?ts|[tj]sx)$/`). - The `node_modules` re-resolve now runs for every order but `Package`. Without that, a `.js` file importing a package with `index.js` beside `index.ts` would get `index.ts`. - `require()` is unchanged: it already goes to Node's own CommonJS lookup. ### Tests - Rust: `named_order_tries_the_named_file_first` and `extension_order_follows_the_importer`. - `extension-order.spec.ts`: - the entry point for `.js`, `.mjs`, `.cjs`, `.jsx` and extensionless names, with the TypeScript sibling present and with it missing - `.js`, `.mjs` and `.cjs` importers - a JavaScript importer that finds only TypeScript - a `.jsx` importer - a package reached from JavaScript - `createImporter` with a directory parent - `directory-parent-url.spec.ts`: `--import ./setup.js` with `setup.ts` beside it. - 10 of these fail on `main`. The rest guard what must not change. - `vp run test` and `OXC_TRANSFORM_ALL=true vp run test` pass (588), as do `cargo test`, clippy, lint and fmt. ### Not changed - tsx goes TypeScript first for JavaScript importers and the entry point when tsconfig has `allowJs`. oxc-node does not read `allowJs` for this. Following it would bring this bug back in `allowJs` projects. - `require()` from TypeScript files still uses Node's lookup (JavaScript first), as before. π€ Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Outside
node_modules,import "./App.jsx"fails withERR_MODULE_NOT_FOUNDwhen onlyApp.tsxexists. tsc and tsx resolve a.jsxspecifier to.tsx, then.ts, then.jsx, then.js.This change adds that
.jsxextension alias to the source-first resolver options, next to the existing.js,.mjsand.cjsaliases. Files insidenode_moduleskeep the package order and are unchanged.As with
./dep.jsafter #851,./dep.jsxnow picksdep.tsxwhen both files exist. Theresolved-formattest that keptdep.tsxanddep.jsxside by side now usesother.jsxfor its.jsxprobe, so it still checks the module format of a.jsxfile.Test plan
extension-order.spec.ts:./dep.jsxpicksdep.tsxoverdep.jsx, and./util.jsxfindsutil.ts. It fails onmainwithERR_MODULE_NOT_FOUNDand passes with this change.source_order_tries_typescript_firstasserts the new alias.pnpm test: 550 passed, 19 skipped.cargo test,cargo clippy --all-targets --all-features -- -D warnings,cargo fmt --checkandvp lintpass.Fixes #873