Skip to content

Commit c7fb9cb

Browse files
aduh95juanarbol
authored andcommitted
esm: graduate top-level-await to stable
Removes the experimental label in the docs and makes the `--experimental-top-level-await` flag a no-op. V8 has removed the harmony flag in V8 9.1 and consider the feature stable, there's no reason to keep it experimental in Node.js. PR-URL: #42875 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent e78bcb7 commit c7fb9cb

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

doc/api/esm.md

-2
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ would provide the exports interface for the instantiation of `module.wasm`.
556556
added: v14.8.0
557557
-->
558558
559-
> Stability: 1 - Experimental
560-
561559
The `await` keyword may be used in the top level body of an ECMAScript module.
562560
563561
Assuming an `a.mjs` with

src/module_wrap.cc

+1-7
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,7 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
429429
return;
430430
}
431431

432-
// If TLA is enabled, `result` is the evaluation's promise.
433-
// Otherwise, `result` is the last evaluated value of the module,
434-
// which could be a promise, which would result in it being incorrectly
435-
// unwrapped when the higher level code awaits the evaluation.
436-
if (env->isolate_data()->options()->experimental_top_level_await) {
437-
args.GetReturnValue().Set(result.ToLocalChecked());
438-
}
432+
args.GetReturnValue().Set(result.ToLocalChecked());
439433
}
440434

441435
void ModuleWrap::GetNamespace(const FunctionCallbackInfo<Value>& args) {

src/node_options.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -670,14 +670,8 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
670670
kAllowedInEnvironment);
671671
Implies("--report-signal", "--report-on-signal");
672672

673-
AddOption("--experimental-top-level-await",
674-
"",
675-
&PerIsolateOptions::experimental_top_level_await,
676-
kAllowedInEnvironment);
677-
AddOption("--harmony-top-level-await", "", V8Option{});
678-
Implies("--experimental-top-level-await", "--harmony-top-level-await");
679-
Implies("--harmony-top-level-await", "--experimental-top-level-await");
680-
ImpliesNot("--no-harmony-top-level-await", "--experimental-top-level-await");
673+
AddOption(
674+
"--experimental-top-level-await", "", NoOp{}, kAllowedInEnvironment);
681675

682676
Insert(eop, &PerIsolateOptions::get_per_env_options);
683677
}

src/node_options.h

-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ class PerIsolateOptions : public Options {
199199
bool node_snapshot = true;
200200
bool report_uncaught_exception = false;
201201
bool report_on_signal = false;
202-
bool experimental_top_level_await = true;
203202
std::string report_signal = "SIGUSR2";
204203
inline EnvironmentOptions* get_per_env_options();
205204
void CheckOptions(std::vector<std::string>* errors) override;

0 commit comments

Comments
 (0)