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 <noreply@anthropic.com>
This commit is contained in:
Neil
2026-09-27 15:34:38 -07:00
committed by GitHub
co-authored by Claude
parent 993183afd7
commit 161bdf93c3
2 changed files with 17 additions and 7 deletions
@@ -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)
@@ -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