add require to global
This commit is contained in:
parent
b2d3293a97
commit
63376913de
1 changed files with 2 additions and 1 deletions
3
qjs.c
3
qjs.c
|
@ -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++) {
|
||||||
|
|
Loading…
Reference in a new issue