1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:35:06 +00:00

LibJS: Implement ImportCall and HostImportModuleDynamically

This allows us to load modules from scripts.
This can be dangerous as it can load arbitrary files. Because of that it
fails and throws by default. Currently, only js and JavaScriptTestRunner
enable the default hook.

This also adds tests to test-js which test module code. Because we
form a spec perspective can't "enter" a module this is the easiest way
to run tests without having to modify test-js to have special cases for
modules.
To specify modules in test-js we use the extension '.mjs' this is to
ensure the files are not executed. We do still want to lint these files
so the prettier scripts have changed to look for '.mjs' files as well.
This commit is contained in:
davidot 2022-01-18 19:39:36 +01:00 committed by Linus Groh
parent 023968a489
commit 7cbf4b90e8
17 changed files with 416 additions and 5 deletions

View file

@ -182,8 +182,10 @@ int main(int argc, char** argv)
if (g_main_hook)
g_main_hook();
if (!g_vm)
if (!g_vm) {
g_vm = JS::VM::create();
g_vm->enable_default_host_import_module_dynamically_hook();
}
Test::JS::TestRunner test_runner(test_root, common_path, print_times, print_progress, print_json);
test_runner.run(test_glob);