Javet icon indicating copy to clipboard operation
Javet copied to clipboard

Module cache error

Open aiselp opened this issue 1 year ago • 2 comments
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. image

aiselp avatar Aug 02 '24 09:08 aiselp

Thank you for reporting this issue. It's quite weird. I just fixed it in the dev branch. Please wait for the next release.

caoccao avatar Aug 04 '24 03:08 caoccao

Very strange, just put import events below and it will print fasle

aiselp avatar Aug 04 '24 08:08 aiselp