A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/62bb2e757f below:

unflag Top-Level Await · nodejs/node@62bb2e7 · GitHub

File tree Expand file treeCollapse file tree 14 files changed

+33

-28

lines changed

Filter options

Expand file treeCollapse file tree 14 files changed

+33

-28

lines changed Original file line number Diff line number Diff line change

@@ -239,16 +239,6 @@ the ability to import a directory that has an index file.

239 239 240 240

Please see [customizing ESM specifier resolution][] for example usage.

241 241 242 -

### `--experimental-top-level-await`

243 -

<!-- YAML

244 -

added: v14.3.0

245 -

-->

246 - 247 -

Enable experimental top-level `await` keyword support, available only in ES

248 -

module scripts.

249 - 250 -

(See also `--experimental-repl-await`.)

251 - 252 242

### `--experimental-vm-modules`

253 243

<!-- YAML

254 244

added: v9.6.0

Original file line number Diff line number Diff line change

@@ -1146,9 +1146,8 @@ would provide the exports interface for the instantiation of `module.wasm`.

1146 1146 1147 1147

## Experimental top-level `await`

1148 1148 1149 -

When the `--experimental-top-level-await` flag is provided, `await` may be used

1150 -

in the top level (outside of async functions) within modules. This implements

1151 -

the [ECMAScript Top-Level `await` proposal][].

1149 +

The `await` keyword may be used in the top level (outside of async functions)

1150 +

within modules as per the [ECMAScript Top-Level `await` proposal][].

1152 1151 1153 1152

Assuming an `a.mjs` with

1154 1153

@@ -1166,8 +1165,7 @@ console.log(five); // Logs `5`

1166 1165

```

1167 1166 1168 1167

```bash

1169 -

node b.mjs # fails

1170 -

node --experimental-top-level-await b.mjs # works

1168 +

node b.mjs # works

1171 1169

```

1172 1170 1173 1171

## Experimental loaders

Original file line number Diff line number Diff line change

@@ -157,9 +157,6 @@ keyword support in REPL.

157 157

.It Fl -experimental-specifier-resolution

158 158

Select extension resolution algorithm for ES Modules; either 'explicit' (default) or 'node'

159 159

.

160 -

.It Fl -experimental-top-level-await

161 -

Enable experimental top-level await support in ES modules.

162 -

.

163 160

.It Fl -experimental-vm-modules

164 161

Enable experimental ES module support in VM module.

165 162

.

Original file line number Diff line number Diff line change

@@ -779,6 +779,13 @@ int ProcessGlobalArgs(std::vector<std::string>* args,

779 779

return 12;

780 780

}

781 781 782 +

// TODO(mylesborins): remove this when the harmony-top-level-await flag

783 +

// is removed in V8

784 +

if (std::find(v8_args.begin(), v8_args.end(),

785 +

"--no-harmony-top-level-await") == v8_args.end()) {

786 +

v8_args.push_back("--harmony-top-level-await");

787 +

}

788 + 782 789

auto env_opts = per_process::cli_options->per_isolate->per_env;

783 790

if (std::find(v8_args.begin(), v8_args.end(),

784 791

"--abort-on-uncaught-exception") != v8_args.end() ||

Original file line number Diff line number Diff line change

@@ -613,12 +613,13 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(

613 613

Implies("--report-signal", "--report-on-signal");

614 614 615 615

AddOption("--experimental-top-level-await",

616 -

"enable experimental support for ECMAScript Top-Level Await",

616 +

"",

617 617

&PerIsolateOptions::experimental_top_level_await,

618 618

kAllowedInEnvironment);

619 619

AddOption("--harmony-top-level-await", "", V8Option{});

620 620

Implies("--experimental-top-level-await", "--harmony-top-level-await");

621 621

Implies("--harmony-top-level-await", "--experimental-top-level-await");

622 +

ImpliesNot("--no-harmony-top-level-await", "--experimental-top-level-await");

622 623 623 624

Insert(eop, &PerIsolateOptions::get_per_env_options);

624 625

}

Original file line number Diff line number Diff line change

@@ -188,7 +188,7 @@ class PerIsolateOptions : public Options {

188 188

bool no_node_snapshot = false;

189 189

bool report_uncaught_exception = false;

190 190

bool report_on_signal = false;

191 -

bool experimental_top_level_await = false;

191 +

bool experimental_top_level_await = true;

192 192

std::string report_signal = "SIGUSR2";

193 193

inline EnvironmentOptions* get_per_env_options();

194 194

void CheckOptions(std::vector<std::string>* errors) override;

Original file line number Diff line number Diff line change

@@ -1,5 +1,3 @@

1 -

// Flags: --experimental-top-level-await

2 - 3 1

import '../common/index.mjs';

4 2

import fixtures from '../common/fixtures.js';

5 3

import assert from 'assert';

Original file line number Diff line number Diff line change

@@ -1,2 +1,4 @@

1 +

// Flags: --no-harmony-top-level-await

2 + 1 3

'use strict';

2 4

await async () => 0;

Original file line number Diff line number Diff line change

@@ -1,4 +1,4 @@

1 -

file:///*/test/message/esm_display_syntax_error.mjs:2

1 +

file:///*/test/message/esm_display_syntax_error.mjs:4

2 2

await async () => 0;

3 3

^^^^^

4 4 Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2

2 2

await async () => 0;

3 -

^^^^^

3 +

^^^^^^^^^^^^^

4 4 5 -

SyntaxError: Unexpected reserved word

5 +

SyntaxError: Malformed arrow function parameter list

6 6

at Loader.moduleStrategy (internal/modules/esm/translators.js:*:*)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4