-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Node.js #5
Comments
CheerpJ is a compiler - so you can definitely generate JS, save and deploy it. The on-the-fly dynamic compilation is just a cool fallback. However, CheerpJ compiles from Java byte code to kind of a JavaScript assembly, so it would be prohibitive to pick up the development in JS and move a project forward.
I don’t know much about the Node.js side of things though.
jeff
… On Sep 30, 2017, at 6:06 AM, John Spackman ***@***.***> wrote:
I have a large Java server application that I would love to port to NodeJS but it’s just too big to start that project - assuming that I replaced Tomcat with ExpressJS, are there any restrictions that would prevent NodeJS development?
Although CheerpJ is billed as "on the fly", is it possible to save the generated Javascript and then ditch the Java altogether - making the Javascript code the main repo that is edited and developed going forward?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#5>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AJP8Sr8QOjItN79znXE-7F9kWfLAHn9lks5sniDSgaJpZM4Pphw4>.
|
Node.js is not yet supported in CheerpJ 3 due to licensing restrictions - you can't self-host. You would be able to work around this using the |
I managed to get CheerpJ loaded from the CDN in Node.js using the following module and the const loaderPath = "https://cjrtnc.leaningtech.com/3.0rc2_305";
const [module, buffer] = await Promise.all([
import(loaderPath + "/cj3.js"),
fetch(loaderPath + "/cj3.wasm").then(r => r.arrayBuffer()),
]);
const exports = await module.default({ buffer });
export default async function init(options) {
await exports.cj3Init(options, loaderPath, exports); // error!
return {
runMain: exports.cjRunMain,
runJar: exports.cjRunJar,
runLibrary: exports.cjRunLibrary,
createDisplay: exports.cjCreateDisplay,
fileBlob: exports.cjFileBlob,
getRuntimeResources: exports.cjGetRuntimeResources,
getProguardConfiguration: exports.cjGetProguardConfiguration,
dumpMethod: exports.dumpMethod,
dumpClass: exports.dumpClass,
dumpAllThreads: exports.dumpAllThreads,
};
} This currently throws an error because CheerpJ believes it's in a browser context and tries to do stuff with |
@bates64 did you get this working? |
Not yet @JoseVSeb. As a workaround, on native platforms like those that run Node.js, you should be able to run Java code with a standard JVM/JRE (e.g. OpenJDK). Perhaps check out tools like https://github.com/joeferner/node-java (note: I haven't played with this at all, but it seems like what you might want?). However, approaches like these this won't work if you're in JS/Wasm-only environments like some FaaS platforms. You also have no sandboxing guarantees, so running untrusted user code is out of the question. We might be able to allocate serious development time to getting CheerpJ 3 working with Node.js/Deno/Bun/etc at some point in the future, but sadly we can't give any timescale guarantees. If you have a commercial use case in mind feel free to get in contact and we can work out a way of sponsoring development on this front. |
I have a large Java server application that I would love to port to NodeJS but it’s just too big to start that project - assuming that I replaced Tomcat with ExpressJS, are there any restrictions that would prevent NodeJS development?
Although CheerpJ is billed as "on the fly", is it possible to save the generated Javascript and then ditch the Java altogether - making the Javascript code the main repo that is edited and developed going forward?
The text was updated successfully, but these errors were encountered: