Skip to content

Commit 22b5ec1

Browse files
dfabulichcodebytere
authored andcommitted
cli: support --experimental-top-level-await in NODE_OPTIONS
PR-URL: #33495 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 011fe1d commit 22b5ec1

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

doc/api/cli.md

+1
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ Node.js options that are allowed are:
11851185
* `--experimental-policy`
11861186
* `--experimental-repl-await`
11871187
* `--experimental-specifier-resolution`
1188+
* `--experimental-top-level-await`
11881189
* `--experimental-vm-modules`
11891190
* `--experimental-wasi-unstable-preview1`
11901191
* `--experimental-wasm-modules`

src/node_options.cc

+2-1
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

+4
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)