Open aiselp opened 1 month ago
Please leave the complete code.
V8Host.getNodeInstance().createV8Runtime<NodeRuntime>().use { runtime ->
runtime.v8ModuleResolver = object : JavetBuiltInModuleResolver() {
override fun resolve(
v8Runtime: V8Runtime?,
resourceName: String?,
v8ModuleReferrer: IV8Module?
): IV8Module? {
println("resolve: $resourceName referrer: ${v8ModuleReferrer?.resourceName}")
return super.resolve(v8Runtime, resourceName, v8ModuleReferrer)
}
}
runtime.getExecutor("""
await import("a")
""".trimIndent()).setModule(true).executeVoid()
}
When a module is loaded I want to set something on
import.meta
in the module for the module to use, which by default is just an empty object. The module resolver is set for NodeRuntime, but theimport()
function does not seem to work. When called, it still goes through the nodejs module callback and throws an error like the followingWhen using import with, such as
import fooData from './foo.json' with { type: 'json' };
, it will also be called back by nodejs and imported correctly