You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 257bbbb
Browse filesBrowse the repository at this point in the historyBrowse files
fix: avoid redundant filesystem probes during module resolution
Fixes#809
## Problem
Since v4.21.1, projects with many local imports start 2–4x slower.
Resolving a TypeScript specifier generated doomed extension candidates
(e.g. `./file.ts` → `file.ts.ts`) and probed each one; every miss
triggered a full failed resolution plus Node's eager CommonJS-hint
decoration, which re-enters tsx's patched CJS resolver. The sync-hooks
path (v4.21.1+, Node ≥24.11.1) runs that cascade on the main thread.
## Changes
- `mapTsExtensions()` no longer generates guaranteed-miss candidates:
verbatim TS extensions (`.ts`/`.tsx`/`.mts`/`.cts`) resolve as-is, and
swap-list extensions (`.js`/`.jsx`/`.cjs`/`.mjs`) drop
appended-extension guesses. Extension-less specifiers still search.
- ESM and CJS resolvers skip candidates that provably don't exist (one
`existsSync`) instead of a full failed resolution + error decoration.
Resolution results are unchanged except for pathological
doubled-extension files (`x.js.ts`), aligning tsx with esbuild/tsc.
Covered by `tests/specs/resolution-priority.ts`.
esm-ts benchmark, 1000 modules (Node 24.15, M5 Pro): this PR 804ms vs
4.21.0 1412ms vs 4.21.1 3775ms.
0 commit comments