mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +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:
parent
023968a489
commit
7cbf4b90e8
17 changed files with 416 additions and 5 deletions
|
@ -251,6 +251,8 @@ public:
|
|||
Function<HashMap<PropertyKey, Value>(SourceTextModule const&)> host_get_import_meta_properties;
|
||||
Function<void(Object*, SourceTextModule const&)> host_finalize_import_meta;
|
||||
|
||||
void enable_default_host_import_module_dynamically_hook();
|
||||
|
||||
private:
|
||||
explicit VM(OwnPtr<CustomData>);
|
||||
|
||||
|
@ -262,6 +264,9 @@ private:
|
|||
ThrowCompletionOr<NonnullRefPtr<Module>> resolve_imported_module(ScriptOrModule referencing_script_or_module, ModuleRequest const& specifier);
|
||||
ThrowCompletionOr<void> link_and_eval_module(SourceTextModule& module);
|
||||
|
||||
void import_module_dynamically(ScriptOrModule referencing_script_or_module, ModuleRequest const& specifier, PromiseCapability promise_capability);
|
||||
void finish_dynamic_import(ScriptOrModule referencing_script_or_module, ModuleRequest const& specifier, PromiseCapability promise_capability, Promise* inner_promise);
|
||||
|
||||
Exception* m_exception { nullptr };
|
||||
|
||||
HashMap<String, PrimitiveString*> m_string_cache;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue