Commit d147c08
module: do not invoke resolve hooks twice for imported cjs
Previously the resolve hook can be invoked twice from the
synthetic module evaluation step of imported CJS in the extra
module._load() call that's invoked on the resolved full path.
Add an option to avoid it, since the resolution and loading
has already been done before.
PR-URL: #61529
Fixes: #57125
Refs: #55808
Refs: #56241
Reviewed-By: Jacob Smith <jacob@frende.me>1 parent 17122e5 commit d147c08Copy full SHA for d147c08
5 files changed
+59-11Lines changed: 59 additions & 11 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib/internal/modules
- cjs
- esm
- test
- fixtures
- module-hooks
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+10-8Lines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
235 | 235 | |
236 | 236 | |
237 | 237 | |
238 | | - |
| 238 | + |
239 | 239 | |
240 | 240 | |
241 | 241 | |
| ||
248 | 248 | |
249 | 249 | |
250 | 250 | |
251 | | - |
| 251 | + |
252 | 252 | |
253 | 253 | |
254 | 254 | |
255 | | - |
| 255 | + |
256 | 256 | |
257 | 257 | |
258 | 258 | |
| ||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | |
| 1043 | + |
1043 | 1044 | |
1044 | 1045 | |
1045 | | - |
| 1046 | + |
1046 | 1047 | |
1047 | 1048 | |
1048 | 1049 | |
| ||
1065 | 1066 | |
1066 | 1067 | |
1067 | 1068 | |
1068 | | - |
| 1069 | + |
1069 | 1070 | |
1070 | 1071 | |
1071 | 1072 | |
| ||
1118 | 1119 | |
1119 | 1120 | |
1120 | 1121 | |
1121 | | - |
| 1122 | + |
1122 | 1123 | |
1123 | 1124 | |
1124 | 1125 | |
| ||
1211 | 1212 | |
1212 | 1213 | |
1213 | 1214 | |
| 1215 | + |
1214 | 1216 | |
1215 | 1217 | |
1216 | | - |
| 1218 | + |
1217 | 1219 | |
1218 | 1220 | |
1219 | 1221 | |
| ||
1236 | 1238 | |
1237 | 1239 | |
1238 | 1240 | |
1239 | | - |
| 1241 | + |
1240 | 1242 | |
1241 | 1243 | |
1242 | 1244 | |
|
Collapse file
lib/internal/modules/esm/translators.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/translators.js+10-3Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
100 | 100 | |
101 | 101 | |
102 | 102 | |
| 103 | + |
103 | 104 | |
104 | 105 | |
105 | 106 | |
| ||
132 | 133 | |
133 | 134 | |
134 | 135 | |
135 | | - |
| 136 | + |
| 137 | + |
| 138 | + |
136 | 139 | |
137 | 140 | |
138 | 141 | |
| ||
280 | 283 | |
281 | 284 | |
282 | 285 | |
283 | | - |
| 286 | + |
| 287 | + |
| 288 | + |
284 | 289 | |
285 | 290 | |
286 | 291 | |
| ||
317 | 322 | |
318 | 323 | |
319 | 324 | |
320 | | - |
| 325 | + |
| 326 | + |
| 327 | + |
321 | 328 | |
322 | 329 | |
323 | 330 | |
|
Collapse file
test/fixtures/value.cjs
Copy file name to clipboard+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
Collapse file
test/module-hooks/test-module-hooks-load-import-cjs.js
Copy file name to clipboard+20Lines changed: 20 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 | + |
Collapse file
test/module-hooks/test-module-hooks-resolve-import-cjs.js
Copy file name to clipboard+18Lines changed: 18 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 | + |
0 commit comments