caoccao / Javet

Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding Node.js and V8 in Java.
https://www.caoccao.com/Javet/
Apache License 2.0
636 stars 61 forks source link

Asynchronous dynamic import #334

Open AsyncProxy opened 1 month ago

AsyncProxy commented 1 month ago

I'm getting an error when I'm using an asynchronous dynamic import

import('fs').then(obj => { console.log(obj) })

Error [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified. at importModuleDynamicallyCallback (node:internal/modules/esm/utils:231:9) at c.js:13:1 { code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING' }

caoccao commented 1 month ago

Please review this doc.

AsyncProxy commented 1 month ago

Please review this doc.

I understand this workaround, but your interface start engine doesn't seem to have this setting to solve it

caoccao commented 1 month ago

You may pass the args via options. I haven't tried your case, but you could take a try.

AsyncProxy commented 1 month ago

You may pass the args via options. I haven't tried your case, but you could take a try.

I'm sorry, I still can't do it, can you update it or help me implement it

caoccao commented 1 month ago

You might review this doc for detail.

public NodeRuntimeOptions setConsoleArguments(java.lang.String[] consoleArguments)
AsyncProxy commented 1 month ago

您可以查看此文档以了解详细信息。

public NodeRuntimeOptions setConsoleArguments(java.lang.String[] consoleArguments)

There is no Api in NodeRuntime to get NodeRuntimeOptions