Compartment support for top-level await
ESM does or will soon have support for await at the top-level of a module’s scope. To support this feature, when we choose to support this feature, will require a refactor of the transform-module and module-instance components to surface a new calling convention. importNow will still return a namespace without wrapping in a promise, but will throw if the module has not run to completion. Modules will await the completion of all their shallow imports before executing.
Will this feature be implemented?
This is not on our roadmap but we would entertain help if it’s needed. Just above this link you can find ways to get in touch with us https://github.com/endojs/endo?tab=readme-ov-file#ruminations-on-the-name
I think it's not that hard to implement. StaticModuleRecord could wrap code in an async function, and import could await precompiled function before returning.