From 161bdf93c3f619c602f4635129c1beaae41ae518 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 27 Sep 2026 15:34:38 -0700 Subject: [PATCH] fix(bench): load benchmark modules under test through jiti (#23482) `pnpm run bench:terminal-partial-escape-tail` and `pnpm run bench:worktree-refresh-churn` both died at startup with ERR_MODULE_NOT_FOUND. Each entrypoint static-imported a `src/` module with an explicit `.ts` extension, but bare `node` type-stripping cannot resolve the extensionless relative specifiers *inside* that module's graph (`terminal-partial-escape-tail.ts` -> `./terminal-escape-introducer`, `worktree-catalog-reconciliation.ts` -> `../../../../shared/structural-value-equality`). Routes both through jiti, matching the four benchmarks that already load `src/` TypeScript that way (`pty-source-ack-boundary`, `locale-collator-sort`, `worktree-base-pending-marker`, `wsl-git-shell`). Adding the extension at each import site was the alternative, but `config/tsconfig.node.json` does not set `allowImportingTsExtensions`, so a `.ts` specifier in `src/shared` fails typecheck with TS5097 -- and no file under `src/` uses that shape today. Developer tooling only; no production code changed. Co-authored-by: Claude --- .../terminal-partial-escape-tail-benchmark.mjs | 11 ++++++----- config/scripts/worktree-refresh-churn-benchmark.mjs | 13 +++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/config/scripts/terminal-partial-escape-tail-benchmark.mjs b/config/scripts/terminal-partial-escape-tail-benchmark.mjs index 0337daa4e9d..0ba8e974161 100644 --- a/config/scripts/terminal-partial-escape-tail-benchmark.mjs +++ b/config/scripts/terminal-partial-escape-tail-benchmark.mjs @@ -3,15 +3,16 @@ // baseline with the pre-change shape (unconditional concat + per-code-unit walk). Equivalence is // proven over a corpus first, so the reported speedup cannot come from the gate changing the answer. import { performance } from 'node:perf_hooks' -import { - advancePartialEscapeTail, - extractPartialEscapeTail, - MAX_PARTIAL_ESCAPE_TAIL_LENGTH -} from '../../src/shared/terminal-partial-escape-tail.ts' +import { createJiti } from 'jiti' const CHUNK_BYTES = 16 * 1024 const CHUNKS = 640 const ROUNDS = 7 +// jiti, not a bare `node` import: type-stripping cannot resolve the extensionless +// relative imports inside the module graph under test. +const jiti = createJiti(import.meta.url) +const { advancePartialEscapeTail, extractPartialEscapeTail, MAX_PARTIAL_ESCAPE_TAIL_LENGTH } = + await jiti.import('../../src/shared/terminal-partial-escape-tail.ts') function baselineAdvance(pendingTail, chunk) { const tail = extractPartialEscapeTail(pendingTail + chunk) diff --git a/config/scripts/worktree-refresh-churn-benchmark.mjs b/config/scripts/worktree-refresh-churn-benchmark.mjs index 5a165801ded..9e7fdffcf3c 100644 --- a/config/scripts/worktree-refresh-churn-benchmark.mjs +++ b/config/scripts/worktree-refresh-churn-benchmark.mjs @@ -1,7 +1,16 @@ #!/usr/bin/env node import { performance } from 'node:perf_hooks' -import { planWorktreeSortOrderUpdates } from '../../src/shared/worktree/sort-order-update.ts' -import { reuseEqualCatalogRows } from '../../src/renderer/src/store/slices/worktree-catalog-reconciliation.ts' +import { createJiti } from 'jiti' + +// jiti, not a bare `node` import: type-stripping cannot resolve the extensionless +// relative imports inside the module graph under test. +const jiti = createJiti(import.meta.url) +const { planWorktreeSortOrderUpdates } = await jiti.import( + '../../src/shared/worktree/sort-order-update.ts' +) +const { reuseEqualCatalogRows } = await jiti.import( + '../../src/renderer/src/store/slices/worktree-catalog-reconciliation.ts' +) const WORKTREE_COUNT = 655 const TAB_COUNT = 1_895