top-level await

Using await directly in the body of an ES module, outside any async function, so the module waits for a promise before it finishes loading.

In more detail

Modules that import it wait too, which is handy for loading configuration before a server starts. It only works in ES modules because CommonJS loads files synchronously.

Related terms

Taught in

References