From e1bc88764d7596925d377845175e7373c3c7e763 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 28 Apr 2022 19:54:29 +0200 Subject: [PATCH] esm: graduate top-level-await to stable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/42875 Reviewed-By: Jacob Smith Reviewed-By: Michaël Zasso Reviewed-By: Benjamin Gruenbaum Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Mestery Reviewed-By: Geoffrey Booth Reviewed-By: Darshan Sen Reviewed-By: Tobias Nießen --- doc/api/esm.md | 2 -- src/module_wrap.cc | 8 +------- src/node_options.cc | 10 ++-------- src/node_options.h | 1 - 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 8c54a6a15e8001..75a8e61af3d0fb 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -556,8 +556,6 @@ would provide the exports interface for the instantiation of `module.wasm`. added: v14.8.0 --> -> Stability: 1 - Experimental - The `await` keyword may be used in the top level body of an ECMAScript module. Assuming an `a.mjs` with diff --git a/src/module_wrap.cc b/src/module_wrap.cc index aeb0d2cb37313b..b4b70ec1afd3ea 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -429,13 +429,7 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo& args) { return; } - // If TLA is enabled, `result` is the evaluation's promise. - // Otherwise, `result` is the last evaluated value of the module, - // which could be a promise, which would result in it being incorrectly - // unwrapped when the higher level code awaits the evaluation. - if (env->isolate_data()->options()->experimental_top_level_await) { - args.GetReturnValue().Set(result.ToLocalChecked()); - } + args.GetReturnValue().Set(result.ToLocalChecked()); } void ModuleWrap::GetNamespace(const FunctionCallbackInfo& args) { diff --git a/src/node_options.cc b/src/node_options.cc index f4b6f3884e4588..6e9c40f98581d4 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -670,14 +670,8 @@ PerIsolateOptionsParser::PerIsolateOptionsParser( kAllowedInEnvironment); Implies("--report-signal", "--report-on-signal"); - AddOption("--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"); - ImpliesNot("--no-harmony-top-level-await", "--experimental-top-level-await"); + AddOption( + "--experimental-top-level-await", "", NoOp{}, kAllowedInEnvironment); Insert(eop, &PerIsolateOptions::get_per_env_options); } diff --git a/src/node_options.h b/src/node_options.h index 39ab60ac2542f7..1984849599f5b9 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -199,7 +199,6 @@ class PerIsolateOptions : public Options { bool node_snapshot = true; bool report_uncaught_exception = false; bool report_on_signal = false; - bool experimental_top_level_await = true; std::string report_signal = "SIGUSR2"; inline EnvironmentOptions* get_per_env_options(); void CheckOptions(std::vector* errors) override;