fix require polyfill
This commit is contained in:
parent
18c24ca20e
commit
6930c1ef9d
2 changed files with 11 additions and 4 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -5,6 +5,12 @@ examples/*.so
|
|||
microbench*.txt
|
||||
qjs
|
||||
qjsc
|
||||
qjscalc
|
||||
qjscalc.c
|
||||
hello.c
|
||||
hello
|
||||
hello_module
|
||||
repl.c
|
||||
run-test262
|
||||
test262
|
||||
test262_*.txt
|
||||
|
|
9
qjs.c
9
qjs.c
|
@ -494,11 +494,12 @@ int main(int argc, char **argv)
|
|||
"globalThis.os = os;\n";
|
||||
eval_buf(ctx, str, strlen(str), "<input>", JS_EVAL_TYPE_MODULE);
|
||||
}
|
||||
|
||||
//POLYFILLS BEGIN
|
||||
const char *reqPF = "function require(x) { \n"
|
||||
" import { y } from `String(x)` \n"
|
||||
" return y \n"
|
||||
"}";
|
||||
const char *reqPF = "async function require(x) { {\n"
|
||||
" const y = await import(x);" // use dynamic import.
|
||||
" return y;\n"
|
||||
"}\n";
|
||||
eval_buf(ctx, reqPF, strlen(reqPF), "<input>", JS_EVAL_TYPE_MODULE);
|
||||
|
||||
for(i = 0; i < include_count; i++) {
|
||||
|
|
Loading…
Reference in a new issue