Commit 46cfad4
module: run require.resolve through module.registerHooks()
Previously, require.resolve() called Module._resolveFilename() directly,
bypassing any resolve hooks registered via module.registerHooks(). This
patch fixes that.
PR-URL: #62028
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>1 parent 309f37b commit 46cfad4Copy full SHA for 46cfad4
15 files changed
+348-50Lines changed: 348 additions & 50 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib/internal/modules
- cjs
- esm
- test
- fixtures/module-hooks
- module-hooks
- parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
lib/internal/modules/cjs/loader.js
Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js+60-40Lines changed: 60 additions & 40 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1035 | 1035 | |
1036 | 1036 | |
1037 | 1037 | |
| 1038 | + |
1038 | 1039 | |
1039 | | - |
1040 | | - |
| 1040 | + |
| 1041 | + |
1041 | 1042 | |
1042 | 1043 | |
1043 | 1044 | |
1044 | | - |
| 1045 | + |
1045 | 1046 | |
1046 | 1047 | |
1047 | | - |
1048 | | - |
1049 | | - |
1050 | | - |
1051 | | - |
1052 | | - |
1053 | | - |
1054 | | - |
1055 | | - |
1056 | | - |
1057 | | - |
1058 | | - |
1059 | | - |
1060 | | - |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | | - |
| 1048 | + |
| 1049 | + |
| 1050 | + |
| 1051 | + |
| 1052 | + |
| 1053 | + |
| 1054 | + |
| 1055 | + |
| 1056 | + |
| 1057 | + |
| 1058 | + |
| 1059 | + |
| 1060 | + |
| 1061 | + |
| 1062 | + |
| 1063 | + |
| 1064 | + |
| 1065 | + |
| 1066 | + |
| 1067 | + |
| 1068 | + |
| 1069 | + |
1065 | 1070 | |
1066 | | - |
| 1071 | + |
1067 | 1072 | |
| 1073 | + |
| 1074 | + |
1068 | 1075 | |
| 1076 | + |
| 1077 | + |
| 1078 | + |
| 1079 | + |
| 1080 | + |
| 1081 | + |
| 1082 | + |
| 1083 | + |
| 1084 | + |
| 1085 | + |
| 1086 | + |
| 1087 | + |
| 1088 | + |
| 1089 | + |
| 1090 | + |
| 1091 | + |
1069 | 1092 | |
1070 | 1093 | |
1071 | | - |
1072 | | - |
| 1094 | + |
1073 | 1095 | |
1074 | 1096 | |
1075 | 1097 | |
| ||
1098 | 1120 | |
1099 | 1121 | |
1100 | 1122 | |
1101 | | - |
| 1123 | + |
| 1124 | + |
1102 | 1125 | |
| 1126 | + |
1103 | 1127 | |
1104 | 1128 | |
| 1129 | + |
| 1130 | + |
1105 | 1131 | |
1106 | | - |
1107 | | - |
| 1132 | + |
| 1133 | + |
| 1134 | + |
1108 | 1135 | |
1109 | 1136 | |
1110 | 1137 | |
1111 | 1138 | |
1112 | | - |
1113 | | - |
1114 | | - |
1115 | | - |
1116 | | - |
1117 | | - |
1118 | | - |
1119 | | - |
1120 | | - |
1121 | | - |
| 1139 | + |
| 1140 | + |
| 1141 | + |
1122 | 1142 | |
1123 | 1143 | |
1124 | 1144 | |
| ||
1213 | 1233 | |
1214 | 1234 | |
1215 | 1235 | |
1216 | | - |
| 1236 | + |
1217 | 1237 | |
1218 | 1238 | |
1219 | | - |
| 1239 | + |
1220 | 1240 | |
1221 | 1241 | |
1222 | 1242 | |
| ||
1239 | 1259 | |
1240 | 1260 | |
1241 | 1261 | |
1242 | | - |
| 1262 | + |
1243 | 1263 | |
1244 | 1264 | |
1245 | 1265 | |
|
Collapse file
lib/internal/modules/esm/loader.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/loader.js+5-2Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
722 | 722 | |
723 | 723 | |
724 | 724 | |
| 725 | + |
| 726 | + |
| 727 | + |
725 | 728 | |
726 | 729 | |
727 | | - |
| 730 | + |
728 | 731 | |
729 | 732 | |
730 | 733 | |
731 | | - |
| 734 | + |
732 | 735 | |
733 | 736 | |
734 | 737 | |
|
Collapse file
lib/internal/modules/esm/translators.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js+10-5Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
93 | 93 | |
94 | 94 | |
95 | 95 | |
| 96 | + |
| 97 | + |
96 | 98 | |
97 | 99 | |
98 | 100 | |
| ||
163 | 165 | |
164 | 166 | |
165 | 167 | |
166 | | - |
167 | | - |
168 | | - |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
169 | 173 | |
170 | 174 | |
171 | 175 | |
172 | 176 | |
173 | | - |
| 177 | + |
| 178 | + |
174 | 179 | |
175 | 180 | |
176 | 181 | |
| ||
400 | 405 | |
401 | 406 | |
402 | 407 | |
403 | | - |
| 408 | + |
404 | 409 | |
405 | 410 | |
406 | 411 | |
|
Collapse file
lib/internal/modules/helpers.js
Copy file name to clipboardExpand all lines: lib/internal/modules/helpers.js+18-1Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
40 | 40 | |
41 | 41 | |
42 | 42 | |
| 43 | + |
43 | 44 | |
44 | 45 | |
45 | 46 | |
| ||
160 | 161 | |
161 | 162 | |
162 | 163 | |
163 | | - |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
164 | 181 | |
165 | 182 | |
166 | 183 | |
|
Collapse file
test/fixtures/module-hooks/require-resolve-caller.js
Copy file name to clipboard+4Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
Collapse file
test/fixtures/module-hooks/require-resolve-paths-caller.js
Copy file name to clipboard+13Lines changed: 13 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 | + |
Collapse file
test/module-hooks/test-module-hooks-resolve-require-resolve-builtin.js
Copy file name to clipboard+25Lines changed: 25 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 | + |
Collapse file
test/module-hooks/test-module-hooks-resolve-require-resolve-consistency.js
Copy file name to clipboard+38Lines changed: 38 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 | + |
Collapse file
test/module-hooks/test-module-hooks-resolve-require-resolve-create-require.js
Copy file name to clipboard+31Lines changed: 31 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 | + |
Collapse file
test/module-hooks/test-module-hooks-resolve-require-resolve-fallthrough.js
Copy file name to clipboard+19Lines changed: 19 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 | + |
0 commit comments