add require to global

This commit is contained in:
The Ghost of FOSS' Past 2024-10-24 15:07:45 -05:00
parent b2d3293a97
commit 63376913de

3
qjs.c
View file

@ -499,7 +499,8 @@ int main(int argc, char **argv)
const char *reqPF = "async function require(x) {\n" const char *reqPF = "async function require(x) {\n"
" const y = await import(x);" // use dynamic import. " const y = await import(x);" // use dynamic import.
" return y;\n" " return y;\n"
"}\n"; "}\n"
"globalThis.require = require;\n";
eval_buf(ctx, reqPF, strlen(reqPF), "<input>", JS_EVAL_TYPE_MODULE); eval_buf(ctx, reqPF, strlen(reqPF), "<input>", JS_EVAL_TYPE_MODULE);
for(i = 0; i < include_count; i++) { for(i = 0; i < include_count; i++) {