// index.jsfunction add(a, b) { return a + b}// Do I need these?// globalThis.add = add// export { add }
// main.rsasync fn main_async() { let main_module = resolve_path( "./index.js", env::current_dir().unwrap().join("js").as_path() ).unwrap(); let mut js_runtime = JsRuntime::new(RuntimeOptions { module_loader: Some(Rc::new(FsModuleLoader)), ..Default::default() }); let mod_id = js_runtime.load_main_module(&main_module, None).await.unwrap(); let result = js_runtime.mod_evaluate(mod_id); js_runtime.run_event_loop(PollEventLoopOptions::default()).await.unwrap(); result.await.unwrap();}fn main() { let runtime = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); runtime.block_on(main_async())}
add(1, 2)