From 15ffddb20a9f4fdf7f31840965511b63198007d5 Mon Sep 17 00:00:00 2001 From: Sneed Group Holder Date: Thu, 24 Oct 2024 15:30:03 -0500 Subject: [PATCH] unmove --- qjs.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/qjs.c b/qjs.c index 15230b0..284cb2b 100644 --- a/qjs.c +++ b/qjs.c @@ -496,6 +496,15 @@ int main(int argc, char **argv) eval_buf(ctx, str, strlen(str), "", JS_EVAL_TYPE_MODULE); } + //POLYFILLS BEGIN + const char *reqPF = "async function require(x) {\n" + " const y = await import(x);" // use dynamic import. + " return y;\n" + "}\n" + "globalThis.require = require;\n" + "globalThis.global = globalThis;\n"; + eval_buf(ctx, reqPF, strlen(reqPF), "", JS_EVAL_TYPE_MODULE); + for(i = 0; i < include_count; i++) { if (eval_file(ctx, include_list[i], module)) goto fail; @@ -519,20 +528,12 @@ int main(int argc, char **argv) } js_std_loop(ctx); } - //POLYFILLS BEGIN - const char *reqPF = "async function require(x) {\n" - " const y = await import(x);" // use dynamic import. - " return y;\n" - "}\n" - "globalThis.require = require;\n" - "globalThis.global = globalThis;\n"; - eval_buf(ctx, reqPF, strlen(reqPF), "", JS_EVAL_TYPE_MODULE); + if (dump_memory) { JSMemoryUsage stats; JS_ComputeMemoryUsage(rt, &stats); JS_DumpMemoryUsage(stdout, &stats, rt); } - js_std_free_handlers(rt); JS_FreeContext(ctx); JS_FreeRuntime(rt);