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
698 stars 68 forks source link

es mode cannot be used in modules #317

Open 0cococ opened 5 months ago

0cococ commented 5 months ago

The self-encapsulated module can only use the commonjs method and cannot write the es method, otherwise an error will occur. The reasons are as follows. I have enabled the modle mode in package.json and I do not have noop.js locally. The current es method does not seem to be able to use require in the module. () of ES Module /storage/emulated/0/Android/data/com.test/files/debug/node_modules/core/index.js from /storage/emulated/0/Android/data/coco.magichands/files/debug /noop.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.

0cococ commented 5 months ago

Using the latest version of Android node mode

caoccao commented 5 months ago

Have you tried to write a custom module resolver? Node.js ESM in Javet is known to be problematic. You may ping me at discord for details.