@calvinchengx/hellowasm

rustup target add wasm32-unknown-unknown --toolchain nightly cargo +nightly install wasm-bindgen-cli cargo +nightly new hellowasm --lib

Usage no npm install needed!

<script type="module">
  import calvinchengxHellowasm from 'https://cdn.skypack.dev/@calvinchengx/hellowasm';
</script>

README

Hello WASM

Initial Setup

rustup target add wasm32-unknown-unknown --toolchain nightly
cargo +nightly install wasm-bindgen-cli
cargo +nightly new hellowasm --lib

Update cargo.toml

[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"

Development

Build our project

cargo +nightly build --target wasm32-unknown-unknown
wasm-bindgen target/wasm32-unknown-unknown/debug/hellowasm.wasm --out-dir .

Now, in our plain javascript file index.js, we can import our generated hellowasm.js and use the greet function.