mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
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>
This commit is contained in:
1 parent
7dbc0f74d0
commit
14b26e07bd
8 files changed
+18
-18
No files matched your search
+5
-6
@@ -279,12 +279,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
|
||||
@@ -1401,7 +1400,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`
|
||||
@@ -1423,6 +1421,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`
|
||||
|
||||
+4
-3
@@ -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
|
||||
|
||||
+2
-4
@@ -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'.
|
||||
|
||||
+2
-1
@@ -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'));
|
||||
|
||||
+2
-1
@@ -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,
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const repl = require('repl');
|
||||
|
||||
common.skipIfInspectorDisabled();
|
||||
|
||||
// Flags: --expose-internals --experimental-repl-await
|
||||
// Flags: --expose-internals
|
||||
|
||||
const PROMPT = 'await repl > ';
|
||||
|
||||
|
||||
Reference in new issue
Block a user