javy icon indicating copy to clipboard operation
javy copied to clipboard

can javy used to compile a nodejs project ?

Open liufeihe opened this issue 3 years ago • 3 comments

i think this line is the reason throw error,

const mathjs = require('mathjs');

so the javy can not used to compile a nodejs project ?

the errors is below:

thread 'main' panicked at 'called Result::unwrap() on an Err value: Uncaught ReferenceError: 'require' is not defined at (function.mjs:1) ', crates/core/src/main.rs:40:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Error: failed to run main module index.wasm

Caused by: 0: failed to invoke command default 1: error while executing at wasm backtrace: 0: 0x112d1 - !<wasm function 278> 1: 0x10a99 - !<wasm function 277> 2: 0x109e5 - !<wasm function 276> 3: 0x35c4 - !<wasm function 74> 4: 0x131b - !<wasm function 39> 5: 0x23d6 - !<wasm function 55> 6: 0xab5b - !<wasm function 168> 7: 0xa9ca - !<wasm function 167> 8: 0xb557a - !<wasm function 1125> 2: wasm trap: wasm unreachable instruction executed

liufeihe avatar Jan 09 '23 14:01 liufeihe

No, Javy cannot be used to compile a NodeJS project.

jeffcharles avatar Jan 09 '23 18:01 jeffcharles

What you may be able to do if you want to use require to work with JS packages, is use a transpiler like rollup.js to convert your code and its dependencies to a single JS file and then execute that with Javy. However, NodeJS APIs that are outside of what QuickJS provides are not supported.

jeffcharles avatar Jan 09 '23 18:01 jeffcharles

What you may be able to do if you want to use require to work with JS packages, is use a transpiler like rollup.js to convert your code and its dependencies to a single JS file and then execute that with Javy. However, NodeJS APIs that are outside of what QuickJS provides are not supported.

thanks, it's very helpful.

liufeihe avatar Jan 10 '23 03:01 liufeihe