Commit 4de6097
module: reduce circular dependency of internal/modules/cjs/loader
Previously `internal/bootstrap/pre_execution.js` requires
`internal/modules/cjs/loader.js` which in turn requires
`internal/bootstrap/pre_execution.js`. This patch moves the
entry point execution logic out of `pre_execution.js` and
puts it into `internal/modules/run_main.js`. It also tests
that `Module.runMain` can be monkey-patched before further
deprecation/refactoring can be done.
Also added an internal assertion `hasLoadedAnyUserCJSModule`
for documentation purposes.
PR-URL: #30349
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>1 parent 0dd8605 commit 4de6097Copy full SHA for 4de6097
File tree
Expand file treeCollapse file tree
25 files changed
+158
-109
lines changedOpen diff view settings
Filter options
- lib/internal
- bootstrap
- main
- modules
- cjs
- test
- fixtures
- message
- parallel
Expand file treeCollapse file tree
25 files changed
+158
-109
lines changedOpen diff view settings
Collapse file
lib/internal/bootstrap/pre_execution.js
Copy file name to clipboardExpand all lines: lib/internal/bootstrap/pre_execution.js+9-65Lines changed: 9 additions & 65 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
9 | 9 | |
10 | 10 | |
11 | 11 | |
12 | | - |
| 12 | + |
13 | 13 | |
14 | 14 | |
15 | 15 | |
| ||
64 | 64 | |
65 | 65 | |
66 | 66 | |
| 67 | + |
| 68 | + |
| 69 | + |
67 | 70 | |
68 | 71 | |
69 | 72 | |
| ||
398 | 401 | |
399 | 402 | |
400 | 403 | |
401 | | - |
| 404 | + |
| 405 | + |
| 406 | + |
| 407 | + |
| 408 | + |
402 | 409 | |
403 | 410 | |
404 | 411 | |
| ||
446 | 453 | |
447 | 454 | |
448 | 455 | |
449 | | - |
450 | | - |
451 | | - |
452 | | - |
453 | | - |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | | - |
462 | | - |
463 | | - |
464 | | - |
465 | | - |
466 | | - |
467 | | - |
468 | | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | | - |
475 | | - |
476 | | - |
477 | | - |
478 | | - |
479 | | - |
480 | | - |
481 | | - |
482 | | - |
483 | | - |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | | - |
492 | | - |
493 | | - |
494 | | - |
495 | | - |
496 | | - |
497 | | - |
498 | | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | | - |
504 | | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | 456 | |
510 | 457 | |
511 | | - |
512 | | - |
513 | 458 | |
514 | 459 | |
515 | 460 | |
516 | | - |
517 | 461 | |
518 | 462 | |
519 | 463 | |
|
Collapse file
lib/internal/main/run_main_module.js
Copy file name to clipboardExpand all lines: lib/internal/main/run_main_module.js+6-4Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
6 | 6 | |
7 | 7 | |
8 | 8 | |
9 | | - |
10 | | - |
11 | 9 | |
12 | 10 | |
13 | 11 | |
14 | 12 | |
15 | | - |
16 | | - |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
Collapse file
lib/internal/main/worker_thread.js
Copy file name to clipboardExpand all lines: lib/internal/main/worker_thread.js+6-2Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
110 | 110 | |
111 | 111 | |
112 | 112 | |
| 113 | + |
| 114 | + |
| 115 | + |
113 | 116 | |
114 | 117 | |
115 | 118 | |
| ||
138 | 141 | |
139 | 142 | |
140 | 143 | |
141 | | - |
142 | | - |
| 144 | + |
| 145 | + |
| 146 | + |
143 | 147 | |
144 | 148 | |
145 | 149 | |
|
Collapse file
lib/internal/modules/cjs/loader.js
Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js+9-18Lines changed: 9 additions & 18 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
74 | 74 | |
75 | 75 | |
76 | 76 | |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
77 | 81 | |
78 | 82 | |
79 | 83 | |
80 | 84 | |
81 | 85 | |
82 | 86 | |
83 | 87 | |
84 | | - |
85 | | - |
86 | | - |
87 | | - |
88 | | - |
89 | 88 | |
90 | 89 | |
91 | | - |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
92 | 94 | |
93 | 95 | |
94 | 96 | |
| ||
1148 | 1150 | |
1149 | 1151 | |
1150 | 1152 | |
| 1153 | + |
1151 | 1154 | |
1152 | 1155 | |
1153 | 1156 | |
| ||
1197 | 1200 | |
1198 | 1201 | |
1199 | 1202 | |
1200 | | - |
1201 | | - |
1202 | | - |
1203 | | - |
1204 | | - |
1205 | | - |
1206 | | - |
1207 | | - |
1208 | | - |
1209 | | - |
1210 | | - |
1211 | | - |
1212 | 1203 | |
1213 | 1204 | |
1214 | 1205 | |
|
Collapse file
lib/internal/modules/run_main.js
Copy file name to clipboard+80Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
145 | 145 | |
146 | 146 | |
147 | 147 | |
| 148 | + |
148 | 149 | |
149 | 150 | |
150 | 151 | |
|
Collapse file
test/fixtures/monkey-patch-run-main.js
Copy file name to clipboard+8Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
Collapse file
test/message/core_line_numbers.out
Copy file name to clipboardExpand all lines: test/message/core_line_numbers.out+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
10 | 10 | |
11 | 11 | |
12 | 12 | |
13 | | - |
| 13 | + |
14 | 14 | |
Collapse file
test/message/error_exit.out
Copy file name to clipboardExpand all lines: test/message/error_exit.out+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | | - |
| 15 | + |
16 | 16 | |
17 | 17 | |
18 | 18 | |
|
Collapse file
test/message/esm_loader_not_found.out
Copy file name to clipboardExpand all lines: test/message/esm_loader_not_found.out+2-2Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | | - |
15 | | - |
| 14 | + |
| 15 | + |
16 | 16 | |
17 | 17 | |
18 | 18 | |
0 commit comments