-
Notifications
You must be signed in to change notification settings - Fork 114
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
Access the exported methods from a script #396
Comments
I am also actively investigating how to do this for one of our use cases too 😄 |
That's great @jeffcharles! If there's any branch / fork related to this effort, I would be really happy to check it and try to contribute. Any guidance on the required changes here would be helpful to start playing with it 😄 |
I use a simple replacement. It is not a fancy solution, but it does its work. https://github.com/gc-victor/js-wasm-workers-runtime/blob/main/crates/runtime/src/lib.rs#L31 |
Yes, I'm using a similar replacement for some tests now hehe. |
I've got an approach that seems to work though it's a bit messy in https://github.com/bytecodealliance/javy/compare/jc.exported-func-invoke-example?expand=1. I couldn't find a C API that enables us to retrieve the function directly unfortunately. There are C APIs for working with the exports list of a module (for example, |
Thank you @jeffcharles! I think this may work. In my case, I'm using the |
So, before the exported methods is officially supported, how can I execute the wasm built by Javy with browser API Thanks and btw really great work @jeffcharles |
You'll need to use a browser implementation of WASI. Using https://github.com/bjorn3/browser_wasi_shim may work. I don't have a browser example unfortunately. |
A while back, I merged #412 which uses javy/crates/core/src/execution.rs Lines 14 to 25 in 3b02858
|
What is the idea?
Currently, Javy supports ECMAScript modules (ESM) via the
compile_module
JSContext method. It interprets and run any code that includes keywords from the ESM specification likeimport / export
.However, we cannot access to the these exported methods and values after it finishes. For example, given the following JavaScript code, I would like to access to the
fetch
in the exported object:The goal is to expose these methods at the
quickjs-wasm-rs
level, so we can build custom JavaScript runtimes on top of thejavy
crate. For now, I'm not thinking on fetching these exports and setting them as "exported functions" in the Wasm module from thejavy-cli
.What problem does it solve?
ESM modules are more and more common in the JavaScript ecosystem. For example, different projects from the WinterCG started using ESM modules as the way to define workers / functions in their platforms:
For example:
We want to offer the same option in Wasm Workers Server, that relies on Javy for the JavaScript runtime. We need access to those exported methods so we can call those functions from the Rust side.
Here you can find the related issue (vmware-labs/wasm-workers-server/issues/149).
The text was updated successfully, but these errors were encountered: