Modern JS
ES2020+2020 – todayYearly, incremental releases. Small operators that erase enormous amounts of defensive boilerplate, plus top-level await for module-scope asynchrony.
A module can await at its top level. Importers of that module wait for it — the module graph itself becomes asynchronous.
const started = Date.now();
await new Promise((resolve) => setTimeout(resolve, 50));
console.log("module body resumed after", Date.now() - started, "ms");
console.log("importers of this module waited for it");| V8 | Implemented at the engine level since V8 8.9; requires the host to use the async module evaluation API. |
|---|---|
| Node.js | Works in `.mjs` / `"type": "module"` files. Unavailable in CommonJS — a common migration blocker. |
| Deno | Available everywhere, including the REPL, since all modules are ESM by default. |
| Bun | Supported in both ESM and its CommonJS interop layer, which transparently wraps CJS files. |