mirror of
https://github.com/denoland/deno.git
synced 2024-11-27 16:10:57 -05:00
135053486c
This commit changes implementation of top-level-await in "deno_core". Previously promise returned from module evaluation was not awaited, leading to out-of-order execution of modules that have TLA. It's been fixed by changing "JsRuntime::mod_evaluate" to be an async function that resolves when the promise returned from module evaluation also resolves. When waiting for promise resolution event loop is polled repeatedly, until there are no more dynamic imports or pending ops.
21 lines
483 B
JavaScript
21 lines
483 B
JavaScript
// Ported from Node
|
|
// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs
|
|
|
|
const { default: order } = await import("./tla/parent.js");
|
|
|
|
console.log("order", JSON.stringify(order));
|
|
|
|
if (
|
|
!(
|
|
order[0] === "order" &&
|
|
order[1] === "b" &&
|
|
order[2] === "c" &&
|
|
order[3] === "d" &&
|
|
order[4] === "a" &&
|
|
order[5] === "parent"
|
|
)
|
|
) {
|
|
throw new Error("TLA wrong order");
|
|
}
|
|
|
|
console.log("TLA order correct");
|