Commit 2d48d17
module: refactor and clarify async loader hook customizations
- This updates the comments that assume loader hooks must be async
- Differentiate the sync/async loader hook paths in naming
`#customizations` is now `#asyncLoaderHooks` to make it clear
it's from the async APIs.
- Differentiate the paths running on the loader hook thread
(affects the loading of async other loader hooks and are async)
v.s. paths on the main thread calling out to code on the loader
hook thread (do not handle loading of other async loader hooks, and
can be sync by blocking).
- `Hooks` is now `AsyncLoaderHooksOnLoaderHookWorker`
- `CustomizedModuleLoader` is now
`AsyncLoaderHooksProxiedToLoaderHookWorker` and moved into
`lib/internal/modules/esm/hooks.js` as it implements the same
interface as `AsyncLoaderHooksOnLoaderHookWorker`
- `HooksProxy` is now `AsyncLoaderHookWorker`
- Adjust the JSDoc accordingly
- Clarify the "loader worker" as the "async loader hook worker"
i.e. when there's no _async_ loader hook registered, there won't
be this worker, to avoid the misconception that this worker
is spawned unconditionally.
- The code run on the loader hook worker to process
`--experimental-loader` is moved into
`lib/internal/modules/esm/worker.js` for clarity.
- The initialization configuration `forceDefaultLoader` is split
into `shouldSpawnLoaderHookWorker` and `shouldPreloadModules`
as those can be separate.
- `--experimental-vm-modules` is now processed during pre-execution
and no longer part of the initialization of the built-in ESM
loader, as it only exposes the vm APIs of ESM, and is unrelated
to built-in ESM loading.
PR-URL: #60278
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>1 parent 064c8c5 commit 2d48d17Copy full SHA for 2d48d17
File tree
Expand file treeCollapse file tree
9 files changed
+355
-309
lines changedOpen diff view settings
Filter options
- lib/internal
- main
- modules
- esm
- process
- test
- es-module
- parallel
Expand file treeCollapse file tree
9 files changed
+355
-309
lines changedOpen diff view settings
Collapse file
lib/internal/main/worker_thread.js
Copy file name to clipboardExpand all lines: lib/internal/main/worker_thread.js+12-10Lines changed: 12 additions & 10 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | | - |
15 | 14 | |
16 | 15 | |
17 | 16 | |
18 | 17 | |
19 | 18 | |
20 | 19 | |
21 | 20 | |
22 | | - |
| 21 | + |
23 | 22 | |
24 | 23 | |
25 | 24 | |
| ||
138 | 137 | |
139 | 138 | |
140 | 139 | |
141 | | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | + |
146 | 147 | |
147 | 148 | |
148 | 149 | |
| ||
152 | 153 | |
153 | 154 | |
154 | 155 | |
155 | | - |
156 | | - |
157 | | - |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
158 | 160 | |
159 | 161 | |
160 | 162 | |
|
Collapse file
lib/internal/modules/esm/hooks.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/hooks.js+137-11Lines changed: 137 additions & 11 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | | - |
58 | 57 | |
59 | 58 | |
60 | 59 | |
| ||
105 | 104 | |
106 | 105 | |
107 | 106 | |
108 | | - |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | + |
109 | 140 | |
110 | 141 | |
111 | 142 | |
| ||
452 | 483 | |
453 | 484 | |
454 | 485 | |
455 | | - |
| 486 | + |
456 | 487 | |
457 | 488 | |
458 | 489 | |
| ||
462 | 493 | |
463 | 494 | |
464 | 495 | |
465 | | - |
| 496 | + |
466 | 497 | |
467 | 498 | |
468 | | - |
469 | | - |
| 499 | + |
| 500 | + |
| 501 | + |
470 | 502 | |
471 | 503 | |
472 | | - |
| 504 | + |
| 505 | + |
| 506 | + |
| 507 | + |
| 508 | + |
| 509 | + |
473 | 510 | |
474 | 511 | |
475 | 512 | |
| ||
503 | 540 | |
504 | 541 | |
505 | 542 | |
506 | | - |
| 543 | + |
507 | 544 | |
508 | 545 | |
509 | 546 | |
| ||
644 | 681 | |
645 | 682 | |
646 | 683 | |
647 | | - |
| 684 | + |
648 | 685 | |
649 | 686 | |
650 | 687 | |
| ||
757 | 794 | |
758 | 795 | |
759 | 796 | |
| 797 | + |
| 798 | + |
| 799 | + |
| 800 | + |
| 801 | + |
| 802 | + |
| 803 | + |
| 804 | + |
| 805 | + |
| 806 | + |
| 807 | + |
| 808 | + |
| 809 | + |
| 810 | + |
| 811 | + |
| 812 | + |
| 813 | + |
| 814 | + |
| 815 | + |
| 816 | + |
| 817 | + |
| 818 | + |
| 819 | + |
| 820 | + |
| 821 | + |
| 822 | + |
| 823 | + |
| 824 | + |
| 825 | + |
| 826 | + |
| 827 | + |
| 828 | + |
| 829 | + |
| 830 | + |
| 831 | + |
| 832 | + |
| 833 | + |
| 834 | + |
| 835 | + |
| 836 | + |
| 837 | + |
| 838 | + |
| 839 | + |
| 840 | + |
| 841 | + |
| 842 | + |
| 843 | + |
| 844 | + |
| 845 | + |
| 846 | + |
| 847 | + |
| 848 | + |
| 849 | + |
| 850 | + |
| 851 | + |
| 852 | + |
| 853 | + |
| 854 | + |
| 855 | + |
| 856 | + |
| 857 | + |
| 858 | + |
| 859 | + |
| 860 | + |
| 861 | + |
| 862 | + |
| 863 | + |
| 864 | + |
| 865 | + |
| 866 | + |
| 867 | + |
| 868 | + |
| 869 | + |
| 870 | + |
| 871 | + |
| 872 | + |
| 873 | + |
| 874 | + |
| 875 | + |
| 876 | + |
| 877 | + |
| 878 | + |
| 879 | + |
| 880 | + |
| 881 | + |
| 882 | + |
| 883 | + |
| 884 | + |
760 | 885 | |
761 | | - |
762 | | - |
| 886 | + |
| 887 | + |
| 888 | + |
0 commit comments