mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.19k stars 851 forks source link

Question: Is there a recommended way to compile a module with JavaScript compiler? #1689

Closed mio-19 closed 1 month ago

mio-19 commented 1 month ago

I want to call a javascript codebase from Java. It is in node.js package format and has some dependencies. I can use well known tools to bundle and transpile to one module. I would like to pre-compile it to jvm bytecodes and call it from jvm.

I went through the document of JavaScript compiler https://rhino.github.io/tools/javascript_compiler/

The compiler seem to expect some format of global functions definitions if I want to export interface for jvm to use, however none of bundler/transpiler tools support this format.