summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhemanth.hm <hemanth.hm@gmail.com>2021-07-08 18:33:54 +0000
committerBeth Griggs <bgriggs@redhat.com>2021-07-29 11:56:47 +0100
commita082a705b391712758ec9e296ca62653b458f841 (patch)
tree68b1e6a93abde979a73e573f8920acf7880431de
parent6979313abb30d381bf36a95637d96fbd43bee694 (diff)
downloadnode-new-a082a705b391712758ec9e296ca62653b458f841.tar.gz
repl: enable --experimental-repl-await /w opt-out
Unflags top-level await for the REPL by enabling --experimental-repl-await by default. Opt-out is supported via --no-experimental-repl-await. PR-URL: https://github.com/nodejs/node/pull/34733 Reviewed-By: Guy Bedford <guybedford@gmail.com>
-rw-r--r--doc/api/cli.md11
-rw-r--r--doc/api/repl.md7
-rw-r--r--doc/node.16
-rw-r--r--lib/repl.js3
-rw-r--r--src/node_options.cc3
-rw-r--r--src/node_options.h2
-rw-r--r--test/parallel/test-repl-import-referrer.js2
-rw-r--r--test/parallel/test-repl-top-level-await.js2
8 files changed, 18 insertions, 18 deletions
diff --git a/doc/api/cli.md b/doc/api/cli.md
index 8c462bbd6e..a66d8192d3 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -277,12 +277,11 @@ added: v11.8.0
Use the specified file as a security policy.
-### `--experimental-repl-await`
+### `--no-experimental-repl-await`
<!-- YAML
-added: v10.0.0
--->
-
-Enable experimental top-level `await` keyword support in REPL.
+added: REPLACEME
+ -->
+ Use this flag to disable top-level await in REPL.
### `--experimental-specifier-resolution=mode`
<!-- YAML
@@ -1399,7 +1398,6 @@ Node.js options that are allowed are:
* `--experimental-loader`
* `--experimental-modules`
* `--experimental-policy`
-* `--experimental-repl-await`
* `--experimental-specifier-resolution`
* `--experimental-top-level-await`
* `--experimental-vm-modules`
@@ -1421,6 +1419,7 @@ Node.js options that are allowed are:
* `--max-http-header-size`
* `--napi-modules`
* `--no-deprecation`
+* `--no-experimental-repl-await`
* `--no-force-async-hooks-checks`
* `--no-warnings`
* `--node-memory-debug`
diff --git a/doc/api/repl.md b/doc/api/repl.md
index 075fa91581..998ab61800 100644
--- a/doc/api/repl.md
+++ b/doc/api/repl.md
@@ -217,8 +217,7 @@ Error: foo
#### `await` keyword
-With the [`--experimental-repl-await`][] command-line option specified,
-experimental support for the `await` keyword is enabled.
+Support for the `await` keyword is enabled at the top level.
```console
> await Promise.resolve(123)
@@ -250,6 +249,8 @@ undefined
234
```
+[`--no-experimental-repl-await`][] shall disable top-level await in REPL.
+
### Reverse-i-search
<!-- YAML
added:
@@ -764,7 +765,7 @@ For an example of running a REPL instance over [`curl(1)`][], see:
[TTY keybindings]: readline.md#readline_tty_keybindings
[ZSH]: https://en.wikipedia.org/wiki/Z_shell
[`'uncaughtException'`]: process.md#process_event_uncaughtexception
-[`--experimental-repl-await`]: cli.md#cli_experimental_repl_await
+[`--no-experimental-repl-await`]: cli.md#cli_no_experimental_repl_await
[`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`]: errors.md#errors_err_domain_cannot_set_uncaught_exception_capture
[`ERR_INVALID_REPL_INPUT`]: errors.md#errors_err_invalid_repl_input
[`curl(1)`]: https://curl.haxx.se/docs/manpage.html
diff --git a/doc/node.1 b/doc/node.1
index 2cfc4dbda9..29861a7fab 100644
--- a/doc/node.1
+++ b/doc/node.1
@@ -153,10 +153,8 @@ to use as a custom module loader.
.It Fl -experimental-policy
Use the specified file as a security policy.
.
-.It Fl -experimental-repl-await
-Enable experimental top-level
-.Sy await
-keyword support in REPL.
+.It Fl -no-experimental-repl-await
+Disable top-level await keyword support in REPL.
.
.It Fl -experimental-specifier-resolution
Select extension resolution algorithm for ES Modules; either 'explicit' (default) or 'node'.
diff --git a/lib/repl.js b/lib/repl.js
index c73ad5d9d6..fd626e1824 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -149,7 +149,6 @@ const {
validateFunction,
validateObject,
} = require('internal/validators');
-
const experimentalREPLAwait = getOptionValue(
'--experimental-repl-await'
);
@@ -422,6 +421,8 @@ function REPLServer(prompt,
wrappedCmd = true;
}
+ // `experimentalREPLAwait` is set to true by default.
+ // Shall be false in case `--no-experimental-repl-await` flag is used.
if (experimentalREPLAwait && StringPrototypeIncludes(code, 'await')) {
if (processTopLevelAwait === undefined) {
({ processTopLevelAwait } = require('internal/repl/await'));
diff --git a/src/node_options.cc b/src/node_options.cc
index 1e3659cd00..40f8cf8690 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -349,7 +349,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption("--experimental-repl-await",
"experimental await keyword support in REPL",
&EnvironmentOptions::experimental_repl_await,
- kAllowedInEnvironment);
+ kAllowedInEnvironment,
+ true);
AddOption("--experimental-vm-modules",
"experimental ES Module support in vm module",
&EnvironmentOptions::experimental_vm_modules,
diff --git a/src/node_options.h b/src/node_options.h
index d737c4f55a..a751d787d7 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -112,7 +112,7 @@ class EnvironmentOptions : public Options {
std::string experimental_policy;
std::string experimental_policy_integrity;
bool has_policy_integrity_string;
- bool experimental_repl_await = false;
+ bool experimental_repl_await = true;
bool experimental_vm_modules = false;
bool expose_internals = false;
bool frozen_intrinsics = false;
diff --git a/test/parallel/test-repl-import-referrer.js b/test/parallel/test-repl-import-referrer.js
index d77d70a031..1c12567fcd 100644
--- a/test/parallel/test-repl-import-referrer.js
+++ b/test/parallel/test-repl-import-referrer.js
@@ -4,7 +4,7 @@ const assert = require('assert');
const cp = require('child_process');
const fixtures = require('../common/fixtures');
-const args = ['--interactive', '--experimental-repl-await'];
+const args = ['--interactive'];
const opts = { cwd: fixtures.path('es-modules') };
const child = cp.spawn(process.execPath, args, opts);
diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js
index 1388ce9334..a7c3811d5e 100644
--- a/test/parallel/test-repl-top-level-await.js
+++ b/test/parallel/test-repl-top-level-await.js
@@ -8,7 +8,7 @@ const repl = require('repl');
common.skipIfInspectorDisabled();
-// Flags: --expose-internals --experimental-repl-await
+// Flags: --expose-internals
const PROMPT = 'await repl > ';