I have some JS code that looks roughly like this:
let ssr = async (arg) => arg || "hello js";
export {ssr as default};
I want to access and call ssr from Java.
How can I do that?
I've been trying something like this:
var ctx = Context.newBuilder("js")
.allowIO(true)
.allowHostAccess(HostAccess.ALL)
.build();
var ssrResource = new String(Server.class.getResourceAsStream("/ssr.mjs").readAllBytes());
ctx.eval(Source
.newBuilder("js", ssrResource, "ssr.mjs")
.build());
var ssr = ctx.getBindings("js").getMember("ssr");
But this always returns null.