Commit 69df688
module: fix sync hook short-circuit in require() in imported CJS
- For imported CJS, if it's not customized by asynchronous hooks,
make sure it won't use the quirky re-invented require in all
cases.
- When the imported CJS module is customized by synchronous hooks,
in the synthetic module evalutation step, avoid calling the
respective default step again.
- Make the branching of loadCJSModuleWithModuleLoad() and
loadCJSModuleWithSpecialRequire() more explicit, and fold
the tentative fs read in the 'commonjs' translator into the
share createCJSModuleWrap() helper instead of checking it
twice in the same path.
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: #62920
Fixes: #63060
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>1 parent 30e71c7 commit 69df688
6 files changed
Lines changed: 265 additions & 89 deletions
File tree
- lib/internal
- modules
- cjs
- esm
- test_runner/mock
- test/module-hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1095 | 1095 | | |
1096 | 1096 | | |
1097 | 1097 | | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1098 | 1107 | | |
1099 | 1108 | | |
1100 | 1109 | | |
1101 | 1110 | | |
1102 | 1111 | | |
1103 | 1112 | | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
| 1113 | + | |
1108 | 1114 | | |
1109 | 1115 | | |
1110 | | - | |
1111 | | - | |
| 1116 | + | |
| 1117 | + | |
1112 | 1118 | | |
1113 | 1119 | | |
1114 | 1120 | | |
| |||
1255 | 1261 | | |
1256 | 1262 | | |
1257 | 1263 | | |
1258 | | - | |
| 1264 | + | |
1259 | 1265 | | |
1260 | 1266 | | |
1261 | | - | |
| 1267 | + | |
1262 | 1268 | | |
1263 | 1269 | | |
1264 | 1270 | | |
| |||
1282 | 1288 | | |
1283 | 1289 | | |
1284 | 1290 | | |
1285 | | - | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
1286 | 1295 | | |
1287 | 1296 | | |
1288 | 1297 | | |
| |||
1370 | 1379 | | |
1371 | 1380 | | |
1372 | 1381 | | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1373 | 1390 | | |
1374 | 1391 | | |
1375 | 1392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
| |||
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | 162 | | |
168 | 163 | | |
169 | 164 | | |
| |||
172 | 167 | | |
173 | 168 | | |
174 | 169 | | |
175 | | - | |
176 | 170 | | |
177 | 171 | | |
178 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
124 | 136 | | |
125 | 137 | | |
126 | 138 | | |
| |||
382 | 394 | | |
383 | 395 | | |
384 | 396 | | |
385 | | - | |
| 397 | + | |
386 | 398 | | |
387 | 399 | | |
388 | 400 | | |
389 | 401 | | |
390 | 402 | | |
391 | | - | |
| 403 | + | |
| 404 | + | |
392 | 405 | | |
393 | 406 | | |
394 | 407 | | |
395 | 408 | | |
396 | 409 | | |
397 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
398 | 416 | | |
399 | 417 | | |
400 | 418 | | |
| |||
443 | 461 | | |
444 | 462 | | |
445 | 463 | | |
446 | | - | |
| 464 | + | |
447 | 465 | | |
448 | 466 | | |
449 | 467 | | |
450 | 468 | | |
451 | | - | |
| 469 | + | |
| 470 | + | |
452 | 471 | | |
453 | 472 | | |
454 | 473 | | |
| |||
470 | 489 | | |
471 | 490 | | |
472 | 491 | | |
473 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
474 | 498 | | |
475 | 499 | | |
476 | 500 | | |
| |||
479 | 503 | | |
480 | 504 | | |
481 | 505 | | |
482 | | - | |
| 506 | + | |
483 | 507 | | |
484 | 508 | | |
485 | 509 | | |
486 | 510 | | |
487 | | - | |
| 511 | + | |
| 512 | + | |