summaryrefslogtreecommitdiff
path: root/Userland/Utilities/js.cpp
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-01-18 19:39:36 +0100
committerLinus Groh <mail@linusgroh.de>2022-01-22 01:21:18 +0000
commit7cbf4b90e872776adcd05ac9150b6f745606aaae (patch)
tree6622fc7fef053fdf810fbc7d2d4a331c7c1bf435 /Userland/Utilities/js.cpp
parent023968a489fdc281ec2bd7f1f04a8bc5a1065cbc (diff)
downloadserenity-7cbf4b90e872776adcd05ac9150b6f745606aaae.zip
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.
Diffstat (limited to 'Userland/Utilities/js.cpp')
-rw-r--r--Userland/Utilities/js.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 40b960e1ab..ea486e09b9 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -1290,6 +1290,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool syntax_highlight = !disable_syntax_highlight;
vm = JS::VM::create();
+ vm->enable_default_host_import_module_dynamically_hook();
+
// NOTE: These will print out both warnings when using something like Promise.reject().catch(...) -
// which is, as far as I can tell, correct - a promise is created, rejected without handler, and a
// handler then attached to it. The Node.js REPL doesn't warn in this case, so it's something we