move polyfills
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / qemu-alpine (arm32v6) (push) Waiting to run
ci / qemu-alpine (arm32v7) (push) Waiting to run
ci / qemu-alpine (arm64v8) (push) Waiting to run
ci / qemu-alpine (i386) (push) Waiting to run
ci / qemu-alpine (s390x) (push) Waiting to run

This commit is contained in:
The Ghost of FOSS' Past 2024-10-24 15:27:46 -05:00
parent a951ae64da
commit 63e1762670

19
qjs.c
View file

@ -496,15 +496,6 @@ int main(int argc, char **argv)
eval_buf(ctx, str, strlen(str), "<input>", 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), "<input>", JS_EVAL_TYPE_MODULE);
for(i = 0; i < include_count; i++) {
if (eval_file(ctx, include_list[i], module))
goto fail;
@ -528,12 +519,20 @@ 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), "<input>", 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);