Commit ab9a579
committed
fix(require-hook): guard require.extensions accesses for Node 24.15+ Yarn PnP
Node.js v24.15.0 introduced a regression (nodejs/node#61769) where the
`require` function exposed to CJS modules loaded via the ESM loader no
longer carries the `.extensions` property when the module source comes
through a custom loader (e.g. Yarn PnP zip loader).
This caused a crash at module evaluation time:
TypeError: Cannot read properties of undefined (reading '.js')
at require-hook.js:35
The fix guards all `require.extensions` accesses with optional chaining
and adds early-return guards in `registerHook`/`deregisterHook` so the
build degrades gracefully instead of crashing.
No behaviour change on Node versions where `require.extensions` is
always defined.
Fixes vercel#929351 parent 1aeb6b1 commit ab9a579
1 file changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | | - | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
40 | | - | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
| |||
0 commit comments