Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esm: graduate top-level-await to stable #42875

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,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
Expand Down
8 changes: 1 addition & 7 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,7 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& 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<Value>& args) {
Expand Down
10 changes: 2 additions & 8 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -704,14 +704,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);
}
Expand Down
1 change: 0 additions & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,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<std::string>* errors) override;
Expand Down