Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
Commit612b870
committed
module: support require()ing synchronous ESM graphs
This patch adds `require()` support for synchronous ESM graphs underthe flag --experimental-require-module.This is based on the the following design aspect of ESM:- The resolution can be synchronous (up to the host)- The evaluation of a synchronous graph (without top-level await) is also synchronous, and, by the time the module graph is instantiated (before evaluation starts), this is is already known.When the module being require()ed has .mjs extension or there areother explicit indicators that it's an ES module, we load it as anES module. If the graph is synchronous, we return the module namespaceas the exports. If the graph contains top-level await, we throw anerror before evaluating the module. If an additional flag--print-pending-tla is passed, we proceeds to evaluation but do notrun the microtasks, only to find out where the TLA is and printtheir location to help users fix them.If there are not explicit indicators whether a .js file is CJS or ESM,we parse it as CJS first. If the parse error indicates that it containsESM syntax, we parse it again as ESM. If the second parsing succeeds,we continue to treat it as ESM.1 parentff4fb7e commit612b870
File tree
15 files changed
+431
-134
lines changed- doc/api
- lib/internal
- modules
- cjs
- esm
- util
- src
- test/es-module
15 files changed
+431
-134
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| 16 | + |
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
871 | 871 |
| |
872 | 872 |
| |
873 | 873 |
| |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
874 | 890 |
| |
875 | 891 |
| |
876 | 892 |
| |
| |||
2523 | 2539 |
| |
2524 | 2540 |
| |
2525 | 2541 |
| |
| 2542 | + | |
2526 | 2543 |
| |
2527 | 2544 |
| |
2528 | 2545 |
| |
|
Lines changed: 66 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
| 63 | + | |
63 | 64 |
| |
64 | 65 |
| |
65 | 66 |
| |
| |||
107 | 108 |
| |
108 | 109 |
| |
109 | 110 |
| |
110 |
| - | |
111 | 111 |
| |
112 | 112 |
| |
113 | 113 |
| |
| |||
161 | 161 |
| |
162 | 162 |
| |
163 | 163 |
| |
| 164 | + | |
| 165 | + | |
164 | 166 |
| |
165 | 167 |
| |
166 | 168 |
| |
| |||
271 | 273 |
| |
272 | 274 |
| |
273 | 275 |
| |
| 276 | + | |
274 | 277 |
| |
275 | 278 |
| |
276 | 279 |
| |
| |||
396 | 399 |
| |
397 | 400 |
| |
398 | 401 |
| |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
399 | 406 |
| |
400 | 407 |
| |
401 | 408 |
| |
| |||
1010 | 1017 |
| |
1011 | 1018 |
| |
1012 | 1019 |
| |
| 1020 | + | |
1013 | 1021 |
| |
1014 | 1022 |
| |
1015 | 1023 |
| |
| |||
1270 | 1278 |
| |
1271 | 1279 |
| |
1272 | 1280 |
| |
1273 |
| - | |
1274 |
| - | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1275 | 1284 |
| |
1276 | 1285 |
| |
1277 |
| - | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
1278 | 1292 |
| |
1279 | 1293 |
| |
1280 |
| - | |
1281 |
| - | |
1282 |
| - | |
1283 |
| - | |
1284 |
| - | |
1285 |
| - | |
1286 |
| - | |
1287 |
| - | |
1288 |
| - | |
1289 |
| - | |
| 1294 | + | |
1290 | 1295 |
| |
1291 |
| - | |
1292 |
| - | |
1293 |
| - | |
1294 |
| - | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
1295 | 1302 |
| |
1296 |
| - | |
1297 |
| - | |
1298 |
| - | |
1299 |
| - | |
1300 |
| - | |
1301 |
| - | |
1302 |
| - | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
1303 | 1306 |
| |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
1304 | 1323 |
| |
1305 | 1324 |
| |
1306 | 1325 |
| |
1307 | 1326 |
| |
1308 | 1327 |
| |
1309 | 1328 |
| |
1310 | 1329 |
| |
| 1330 | + | |
1311 | 1331 |
| |
1312 |
| - | |
| 1332 | + | |
1313 | 1333 |
| |
1314 | 1334 |
| |
1315 | 1335 |
| |
| |||
1319 | 1339 |
| |
1320 | 1340 |
| |
1321 | 1341 |
| |
1322 |
| - | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
1323 | 1353 |
| |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
1324 | 1357 |
| |
1325 | 1358 |
| |
1326 | 1359 |
| |
| |||
1344 | 1377 |
| |
1345 | 1378 |
| |
1346 | 1379 |
| |
| 1380 | + | |
1347 | 1381 |
| |
1348 | 1382 |
| |
1349 | 1383 |
| |
| |||
1370 | 1404 |
| |
1371 | 1405 |
| |
1372 | 1406 |
| |
| 1407 | + | |
1373 | 1408 |
| |
1374 | 1409 |
| |
1375 | 1410 |
| |
| |||
1378 | 1413 |
| |
1379 | 1414 |
| |
1380 | 1415 |
| |
1381 |
| - | |
| 1416 | + | |
| 1417 | + | |
1382 | 1418 |
| |
1383 | 1419 |
| |
1384 | 1420 |
| |
| |||
1414 | 1450 |
| |
1415 | 1451 |
| |
1416 | 1452 |
| |
1417 |
| - | |
| 1453 | + | |
| 1454 | + | |
1418 | 1455 |
| |
1419 | 1456 |
| |
1420 | 1457 |
| |
|
Lines changed: 29 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
| |||
228 | 229 |
| |
229 | 230 |
| |
230 | 231 |
| |
231 |
| - | |
232 |
| - | |
233 |
| - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
234 | 235 |
| |
235 | 236 |
| |
236 |
| - | |
| 237 | + | |
237 | 238 |
| |
238 | 239 |
| |
239 | 240 |
| |
| |||
244 | 245 |
| |
245 | 246 |
| |
246 | 247 |
| |
247 |
| - | |
| 248 | + | |
248 | 249 |
| |
249 | 250 |
| |
250 | 251 |
| |
| |||
261 | 262 |
| |
262 | 263 |
| |
263 | 264 |
| |
264 |
| - | |
| 265 | + | |
265 | 266 |
| |
266 | 267 |
| |
267 | 268 |
| |
| |||
274 | 275 |
| |
275 | 276 |
| |
276 | 277 |
| |
277 |
| - | |
| 278 | + | |
278 | 279 |
| |
279 | 280 |
| |
280 | 281 |
| |
| |||
358 | 359 |
| |
359 | 360 |
| |
360 | 361 |
| |
361 |
| - | |
362 |
| - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
363 | 367 |
| |
364 | 368 |
| |
365 |
| - | |
| 369 | + | |
366 | 370 |
| |
367 | 371 |
| |
368 | 372 |
| |
369 | 373 |
| |
370 | 374 |
| |
371 | 375 |
| |
372 | 376 |
| |
373 |
| - | |
| 377 | + | |
374 | 378 |
| |
375 | 379 |
| |
376 | 380 |
| |
377 | 381 |
| |
378 | 382 |
| |
379 | 383 |
| |
380 | 384 |
| |
| 385 | + | |
381 | 386 |
| |
382 | 387 |
| |
383 | 388 |
| |
| |||
398 | 403 |
| |
399 | 404 |
| |
400 | 405 |
| |
401 |
| - | |
| 406 | + | |
402 | 407 |
| |
403 |
| - | |
404 |
| - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
405 | 417 |
| |
406 | 418 |
| |
| 419 | + | |
| 420 | + | |
407 | 421 |
| |
408 |
| - | |
| 422 | + | |
409 | 423 |
| |
410 | 424 |
| |
411 | 425 |
| |
|
0 commit comments
Comments
(0)