top-level-await support - follow the spec in the implementation of the module linking and evaluation to avoid errors with cycling module dependencies

This commit is contained in:
Fabrice Bellard
2023-12-27 17:10:47 +01:00
parent 9b587c461b
commit 6e4931c4ad
5 changed files with 668 additions and 99 deletions

View File

@@ -3274,6 +3274,7 @@ static void *worker_func(void *opaque)
JSRuntime *rt;
JSThreadState *ts;
JSContext *ctx;
JSValue promise;
rt = JS_NewRuntime();
if (rt == NULL) {
@@ -3300,8 +3301,11 @@ static void *worker_func(void *opaque)
js_std_add_helpers(ctx, -1, NULL);
if (!JS_RunModule(ctx, args->basename, args->filename))
promise = JS_LoadModule(ctx, args->basename, args->filename);
if (JS_IsException(promise))
js_std_dump_error(ctx);
/* XXX: check */
JS_FreeValue(ctx, promise);
free(args->filename);
free(args->basename);
free(args);