Javet
Javet copied to clipboard
Module cache error
trafficstars
V8Host.getNodeInstance().createV8Runtime<NodeRuntime>().use { runtime ->
runtime.getNodeModule(NodeModuleModule::class.java).setRequireRootDirectory(File("/"))
runtime.v8ModuleResolver = JavetBuiltInModuleResolver()
runtime.getExecutor("""
import events from "node:events"
import stream from "node:stream"
globalThis.a = events === stream
""".trimIndent()).setModule(true).executeVoid()
runtime.await()
println("a: ${runtime.globalObject.getBoolean("a")}")
}
This will print true, which means that the same module is returned. If you replace import stream from "node:stream" with const stream = require("node:stream"), it will print false normally.
Thank you for reporting this issue. It's quite weird. I just fixed it in the dev branch. Please wait for the next release.
Very strange, just put import events below and it will print fasle