>
>
> Could we reserve `await` inside the module grammar, so as to make it
> possible for future modules to await promises at top-level, without an
> IIAAFE? This would likely mean even web environments, with their very
> stringent backward-compatibility constraints, would be able to use this
> top-level `await`.
>

I don't think this will work given the staging that happens with module
loading/linking/etc.  But I have another option which I think will work
just fine:

    export async function main() {
      // your async code here
    }

If you export a main function and run that from the command line (e.g. node
my-module-with-main.js), the runtime executes the main module.  This takes
care of some other problems as well, like testing for whether or not the
module is executed as a program versus a library.

Maybe?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to