Skip to content

Commit

Permalink
cli: support --experimental-top-level-await in NODE_OPTIONS
Browse files Browse the repository at this point in the history
PR-URL: #33495
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
dfabulich authored and BridgeAR committed May 23, 2020
1 parent 1acc14b commit 842a895
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ Node.js options that are allowed are:
* `--experimental-policy`
* `--experimental-repl-await`
* `--experimental-specifier-resolution`
* `--experimental-top-level-await`
* `--experimental-vm-modules`
* `--experimental-wasi-unstable-preview1`
* `--experimental-wasm-modules`
Expand Down
3 changes: 2 additions & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(

AddOption("--experimental-top-level-await",
"enable experimental support for ECMAScript Top-Level Await",
&PerIsolateOptions::experimental_top_level_await);
&PerIsolateOptions::experimental_top_level_await,
kAllowedInEnvironment);
AddOption("--harmony-top-level-await", "", V8Option{});
Implies("--experimental-top-level-await", "--harmony-top-level-await");
Implies("--harmony-top-level-await", "--experimental-top-level-await");
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-cli-node-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ expect('--stack-trace-limit=100',
if (!['arm', 'arm64', 's390x'].includes(process.arch))
expect('--interpreted-frames-native-stack', 'B\n');

// Workers can't eval as ES Modules. https://github.com/nodejs/node/issues/30682
expectNoWorker('--experimental-top-level-await --input-type=module',
'B\n', 'console.log(await "B")');

function expectNoWorker(opt, want, command, wantsError) {
expect(opt, want, command, wantsError, false);
}
Expand Down

0 comments on commit 842a895

Please sign in to comment.