Skip to content

Commit f8992f1

Browse files
perf: use sync module hooks on Node v22.22.3+
## Problem tsx uses the sync `module.registerHooks()` path (no loader worker thread) only once Node can re-enter `Module._load` from sync hooks ([nodejs/node#59929](nodejs/node#59929)). That landed in v24.11.1 / v25.1.0 and was **also backported to v22.22.3**, but the gate had no 22.x entry — so v22.22.3+ kept taking the slower async `module.register()` path. ## Changes - Add `[22, 22, 3]` to the `moduleRegisterHooksCjsReload` gate. v22.22.2 and earlier stay on the async path; v22.22.3+ now uses sync hooks. - Bump the 22.x CI matrix entry `22.22.2` → `22.22.3` so CI exercises the newly-enabled sync path on the 22 line. Verified the backport is behaviorally complete: the full suite (incl. CJS-interop, `require.cache`, watch, version-sensitive) passes with Node 22.22.3 as the runner. Startup on Node 22.22.3, 1000 modules (min of 6 runs, M5 Pro): ``` async (before) sync (this PR) hooks-passthrough 437ms 190ms esm-ts 694ms 337ms ```
1 parent 1dfad37 commit f8992f1

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/utils/node-features.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ export const moduleRegister: Version[] = [
6666
// https://github.com/nodejs/node/pull/59929
6767
// https://github.com/nodejs/node/blob/v24.11.1/lib/internal/modules/esm/load.js#L144-L171
6868
// https://github.com/nodejs/node/blob/v24.11.1/lib/internal/modules/esm/translators.js#L345-L356
69+
// Backported to v22.22.3:
70+
// https://github.com/nodejs/node/blob/v22.22.3/lib/internal/modules/esm/load.js#L148-L175
71+
// https://github.com/nodejs/node/blob/v22.22.3/lib/internal/modules/esm/translators.js#L331-L362
6972
export const moduleRegisterHooksCjsReload: Version[] = [
73+
[22, 22, 3],
7074
[24, 11, 1],
7175
[25, 1, 0],
7276
[26, 0, 0],

‎tests/utils/node-versions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const nodeVersions = [
1515
? [
1616
latestMajor('26.1.0'),
1717
latestMajor('25.9.0'),
18-
latestMajor('22.22.2'),
18+
latestMajor('22.22.3'),
1919
latestMajor('21.7.3'),
2020
latestMajor('20.20.2'),
2121
latestMajor('18.20.8'),

0 commit comments

Comments
 (0)