Commit 614ca32
lib: add assertion for user ESM execution
Previously we only had an internal assertion to ensure certain
code is executed before any user-provided CJS is run. This patch
adds another assertion for ESM.
Note that this internal state is not updated during source text
module execution via vm because to run any code via vm, some
user JS code must have already been executed anyway.
In addition this patch moves the states into internal/modules/helpers
to avoid circular dependencies. Also moves toggling the states to
true *right before* user code execution instead of after in case
we are half-way in the execution when internals try to check them.
PR-URL: #51748
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>1 parent 92e7c31 commit 614ca32Copy full SHA for 614ca32
File tree
Expand file treeCollapse file tree
4 files changed
+38
-8
lines changedOpen diff view settings
Filter options
- lib/internal
- modules
- cjs
- esm
- process
Expand file treeCollapse file tree
4 files changed
+38
-8
lines changedOpen diff view settings
Collapse file
lib/internal/modules/cjs/loader.js
Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js+2-5Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | | - |
80 | 79 | |
81 | 80 | |
82 | 81 | |
| ||
113 | 112 | |
114 | 113 | |
115 | 114 | |
| 115 | + |
116 | 116 | |
117 | 117 | |
118 | 118 | |
| ||
127 | 127 | |
128 | 128 | |
129 | 129 | |
130 | | - |
131 | | - |
132 | | - |
133 | 130 | |
134 | 131 | |
135 | 132 | |
| ||
1363 | 1360 | |
1364 | 1361 | |
1365 | 1362 | |
| 1363 | + |
1366 | 1364 | |
1367 | 1365 | |
1368 | 1366 | |
1369 | 1367 | |
1370 | 1368 | |
1371 | 1369 | |
1372 | 1370 | |
1373 | | - |
1374 | 1371 | |
1375 | 1372 | |
1376 | 1373 | |
|
Collapse file
lib/internal/modules/esm/module_job.js
Copy file name to clipboardExpand all lines: lib/internal/modules/esm/module_job.js+5-1Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | | - |
| 30 | + |
| 31 | + |
| 32 | + |
31 | 33 | |
32 | 34 | |
33 | 35 | |
| ||
206 | 208 | |
207 | 209 | |
208 | 210 | |
| 211 | + |
209 | 212 | |
210 | 213 | |
211 | 214 | |
| ||
214 | 217 | |
215 | 218 | |
216 | 219 | |
| 220 | + |
217 | 221 | |
218 | 222 | |
219 | 223 | |
|
Collapse file
lib/internal/modules/helpers.js
Copy file name to clipboardExpand all lines: lib/internal/modules/helpers.js+25Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
319 | 319 | |
320 | 320 | |
321 | 321 | |
| 322 | + |
| 323 | + |
| 324 | + |
| 325 | + |
| 326 | + |
| 327 | + |
| 328 | + |
| 329 | + |
| 330 | + |
| 331 | + |
| 332 | + |
| 333 | + |
| 334 | + |
322 | 335 | |
323 | 336 | |
324 | 337 | |
| ||
328 | 341 | |
329 | 342 | |
330 | 343 | |
| 344 | + |
| 345 | + |
| 346 | + |
| 347 | + |
| 348 | + |
| 349 | + |
| 350 | + |
| 351 | + |
| 352 | + |
| 353 | + |
| 354 | + |
| 355 | + |
331 | 356 | |
Collapse file
lib/internal/process/pre_execution.js
Copy file name to clipboardExpand all lines: lib/internal/process/pre_execution.js+6-2Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
191 | 191 | |
192 | 192 | |
193 | 193 | |
194 | | - |
195 | | - |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
196 | 200 | |
197 | 201 | |
198 | 202 | |
|
0 commit comments