Repository navigation
Broken support for Top-Level Await #33479
Description
Activity
This feature is behind the
--experimental-top-level-awaitflag. See https://github.com/nodejs/node/pull/33473.for updating the documentation.Reacted by Donato AguirreReacted by 8HoLoNEven with
node --experimental-top-level-await test-await.js, it is not working.=>
SyntaxError: await is only valid in async functionIt will only work for esm modules. The default is to use the cjs loader. If you rename
.jsto.mjsit'll work properly. It will also work if you define the loader differently.Reacted by Donato AguirreIt will only work for esm modules. The default is to use the cjs loader. If you rename
.jsto.mjsit'll work properly. It will also work if you define the loader differently.Could it work with the REPL ? (any flag to make REPL context a module context ?)
@8HoLoN we have experimental top level await in the REPL but it's not working identical to the "regular" top level await that's implemented in v14.3.0. You have to use the
--experimental-repl-awaitflag to activate it.Activating ESM is not yet supported in the REPL.
- changed the title
[-]Brokren support for Top-Level Await[/-][+]Broken support for Top-Level Await[/+]on May 20, 2020 I'm trying to figure out if there is something actionable here. Do we need to update docs or changelog? Should we close this?
Reacted by V and DaemonWe could also catch the TLA error in the CJS goal and give a better error message
At minimum I would say, the mandatory flag should be mentioned in changelog and docs. (And that it is only working in top level of es module context)
This got fixed by #33473
What steps will reproduce the bug?
What is the expected behavior?
What do you see instead?