diff --git a/qjs.c b/qjs.c index aa559f7..e963cc5 100644 --- a/qjs.c +++ b/qjs.c @@ -624,7 +624,7 @@ start: if (!empty_run) { js_std_add_helpers(ctx, argc - optind, argv + optind); - //POLYFILLS FOR QJS FILES BEGIN + //POLYFILLS const char *pf = "globalThis.global = globalThis;\n" "global.console.error = console.log\n" "global.console.warn = console.log\n" @@ -652,20 +652,18 @@ start: " console.error('std is not defined.');\n" "}\n"; - /* make 'std' and 'os' visible to non module code */ - if (load_std) { - const char *str = + const stdAndOS *str = "import * as bjson from 'qjs:bjson';\n" "import * as std from 'qjs:std';\n" "import * as os from 'qjs:os';\n" "globalThis.bjson = bjson;\n" "globalThis.std = std;\n" "globalThis.os = os;\n"; - eval_buf(ctx, str, strlen(str), "", JS_EVAL_TYPE_MODULE); - eval_buf(ctx, pf, strlen(pf), "", JS_EVAL_TYPE_MODULE); - } else { - eval_buf(ctx, pf, strlen(pf), "", JS_EVAL_TYPE_MODULE); - } + + + /* make 'std' 'os' and polyfills visible to non module code */ + eval_buf(ctx, stdAndOS, strlen(stdAndOS), "", JS_EVAL_TYPE_MODULE); + eval_buf(ctx, pf, strlen(pf), "", JS_EVAL_TYPE_MODULE); for(i = 0; i < include_count; i++) { if (eval_file(ctx, include_list[i], 0))