oracle / graaljs

A ECMAScript 2023 compliant JavaScript implementation built on GraalVM. With polyglot language interoperability support. Running Node.js applications!
Universal Permissive License v1.0
1.77k stars 188 forks source link

About embedded node-graaljs #341

Closed frank-dspeed closed 3 years ago

frank-dspeed commented 4 years ago

I am at present wondering why the GraalVM page says that NodeJS is not Embedded Able into the JVM there are for example 2 Projects that do exactly that to run JavaScript (Node.JS+v8) via JNI inside android

maybe we can get node-graaljs compiled into a libnode.so that we can call ? like it is done in the other projects?

node-mobile

Most Current Project full NodeJS Support https://github.com/JaneaSystems/nodejs-mobile-samples uses libnode.so build from https://github.com/JaneaSystems/nodejs-mobile they offer binary downloads already and it is NodeJS 12.16 with custom headers

LiquidCore

Node 10 https://github.com/LiquidPlayer/LiquidCore has node_modules the internal once as java replacement also uses custom libnode.so that gets called

wirthi commented 3 years ago

Hi Frank,

Our position is that we currently don't provide the capabilities for running Node.js inside a JVM process. We support:

But of course, that does not rule out other projects manage to extend those features base on Graal.js, like full access to Node.js (including the event loop) from a Java process. An example for that is https://github.com/mikehearn/nodejvm - It is fine to use that for your purposes, but we are not able to provide any support on that.

maybe we can get node-graaljs compiled into a libnode.so that we can call

That might somehow be possible, but remember that this would need to include not only the native parts of Node.js as in the other projects, but also GraalVM's compiler and Graal.js.

Best, Christian

frank-dspeed commented 3 years ago

@wirthi thanks for the answer i just came my self to the conclusion that it is useless to use the node fork

i wil try the context api and shim a nodejs with nativ java objects and some wrappers written in js.