Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.02 KB

README.md

File metadata and controls

33 lines (20 loc) · 1.02 KB

deno-rust-wasm

Test project for Rust and deno interop via WebAssembly.

Run it by building the WebAssembly module and use deno to import / test it:

wasm-pack build && deno main.ts

The problem

Returning a JsValue or a successful result Ok(JsValue) yields a pointer instead of the JsValue?

See returns_js_value_directly and returns_ok_js_value for the Rust implementations and the deno usage.

Strangely, using Err(JsValue) works as you can see in returns_err_js_value and its usage in deno

Another try

wasm-pack build --target web

When initializing through the .js file, the browser stuff seems to work. Deno is still not really happy with it for now.

Working

. start-deno.sh

This changes the default wasm-pack build result to provide an init function. The init function expects a WebAssembly.Module which you get by importing the _bg.wasm file from wasm-pack build.