Skip to content

Commit dffc9e8

Browse files
committed
cli: support --experimental-top-level-await in NODE_OPTIONS
1 parent cd4985c commit dffc9e8

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

doc/api/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,7 @@ Node.js options that are allowed are:
11871187
* `--experimental-policy`
11881188
* `--experimental-repl-await`
11891189
* `--experimental-specifier-resolution`
1190+
* `--experimental-top-level-await`
11901191
* `--experimental-vm-modules`
11911192
* `--experimental-wasi-unstable-preview1`
11921193
* `--experimental-wasm-modules`

src/node_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
599599

600600
AddOption("--experimental-top-level-await",
601601
"enable experimental support for ECMAScript Top-Level Await",
602-
&PerIsolateOptions::experimental_top_level_await);
602+
&PerIsolateOptions::experimental_top_level_await,
603+
kAllowedInEnvironment);
603604
AddOption("--harmony-top-level-await", "", V8Option{});
604605
Implies("--experimental-top-level-await", "--harmony-top-level-await");
605606
Implies("--harmony-top-level-await", "--experimental-top-level-await");

test/parallel/test-cli-node-options.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ expect('--stack-trace-limit=100',
7878
if (!['arm', 'arm64', 's390x'].includes(process.arch))
7979
expect('--interpreted-frames-native-stack', 'B\n');
8080

81+
// Workers can't eval as ES Modules. https://github.com/nodejs/node/issues/30682
82+
expectNoWorker('--experimental-top-level-await --input-type=module',
83+
'B\n', 'console.log(await "B")');
84+
8185
function expectNoWorker(opt, want, command, wantsError) {
8286
expect(opt, want, command, wantsError, false);
8387
}

0 commit comments

Comments
 (0)