Support the import.meta property

Through the `import.meta` property the engine can pass some values to
the module. Currently only the `path` of the script file is exposed.
This commit is contained in:
phosit
2025-01-15 22:15:08 +01:00
committed by phosit
parent a40caaffc4
commit d76e107dca
5 changed files with 52 additions and 0 deletions
+2
View File
@@ -155,6 +155,7 @@ ScriptContext::ScriptContext(int contextSize, uint32_t heapGrowthBytesGCTrigger)
JS::SetPromiseRejectionTrackerCallback(m_cx, &Script::UnhandledRejectedPromise);
JSRuntime* runtime{JS_GetRuntime(m_cx)};
JS::SetModuleMetadataHook(runtime, &Script::ModuleLoader::MetadataHook);
JS::SetModuleResolveHook(runtime, &Script::ModuleLoader::ResolveHook);
JS::SetModuleDynamicImportHook(runtime, &Script::ModuleLoader::DynamicImportHook);
}
@@ -166,6 +167,7 @@ ScriptContext::~ScriptContext()
JSRuntime* runtime{JS_GetRuntime(m_cx)};
JS::SetModuleDynamicImportHook(runtime, nullptr);
JS::SetModuleResolveHook(runtime, nullptr);
JS::SetModuleMetadataHook(runtime, nullptr);
// Switch back to normal performance mode to avoid assertion in debug mode.
js::gc::SetPerformanceHint(m_cx, js::gc::PerformanceHint::Normal);