Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module cache error #376

Open
aiselp opened this issue Aug 2, 2024 · 2 comments
Open

Module cache error #376

aiselp opened this issue Aug 2, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@aiselp
Copy link

aiselp commented Aug 2, 2024

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

caoccao added a commit that referenced this issue Aug 4, 2024
@caoccao
Copy link
Owner

caoccao commented Aug 4, 2024

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 caoccao added the bug Something isn't working label Aug 4, 2024
@caoccao caoccao self-assigned this Aug 4, 2024
@aiselp
Copy link
Author

aiselp commented Aug 4, 2024

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

Repository owner deleted a comment from aiselp Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants