在嵌入式 v8 上具有顶级等待的 ES6 模块

ES6 Modules with top-level await on embedded v8

如何在 ES6 模块中制作顶级等待?我已经使用了常规的 ES6 模块,但是我在带有 v8 的 ES6 模块中找不到关于顶级等待的任何信息。 这是我的代码:

v8::Local<v8::Module> FactoryModule(v8::Isolate* isolate, v8::Local<v8::Context> context, const char* moduleName, const char* code) {
v8::TryCatch tc(context->GetIsolate());
v8::Local<v8::String> source_text = v8::String::NewFromUtf8(
                                        isolate, code)
                                        .ToLocalChecked();

v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, moduleName).ToLocalChecked(),
                        v8::Integer::New(isolate, 0),
                        v8::Integer::New(isolate, 0),
                        v8::False(isolate),
                        v8::Local<v8::Integer>(),
                        v8::Local<v8::Value>(),
                        v8::False(isolate),
                        v8::False(isolate),
                        v8::True(isolate));
v8::Context::Scope context_scope(context);
v8::ScriptCompiler::Source source(source_text, origin);
v8::Local<v8::Module> module = v8::ScriptCompiler::CompileModule(isolate, &source).ToLocalChecked();
// I need to do something before this point as the line above already fails.

V8 中的顶级 await 正在积极开发中,请参阅跟踪错误:https://bugs.chromium.org/p/v8/issues/detail?id=9344