Open eleinadani opened 4 years ago
Initial support for ES modules landed in this commit. Given that the Node.js API is still experimental, not all features are implemented. In particular, we don't support (yet) the "exports"
field in package.json
. However, we already support the "type":"module"
option in package.json
, so we should be able to load basic npm modules already. @pmlopes feedback is welcome!
Are there any night builds? Or in order to test I need to build the whole graalvm myself?
Hi @pmlopes. We have nightly builds, but the GraalVM import of Graal.js is not yet updated. I can ping you when we have a nightly GraalVM build with these changes.
In the meanwhile, if you need just Graal.js + Graal compiler on JDK11, you can:
$ cd graaljs/graal-js
$ mx --dynamicimports /compiler --java-home=PATH_TO_JVMCI_JDK build
$ mx --dynamicimports /compiler --java-home=PATH_TO_JVMCI_JDK graalvm-home
The last step prints the path to the newly built GraalVM.
Add support for loading Node's ES modules through the experimental
require
built-in function.https://nodejs.org/api/esm.html#esm_package_json_type_field https://github.com/graalvm/graaljs/blob/master/docs/user/NodeJSVSJavaScriptContext.md#commonjs-modules-cjs