Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fil1994/rust-wasm-template

a template for Rust WASM and webpack
https://github.com/fil1994/rust-wasm-template

rust wasm web-assembly webpack

Last synced: 3 days ago
JSON representation

a template for Rust WASM and webpack

Awesome Lists containing this project

README

        

# Rust-WASM-Template

NOTE: this is for windows only

## Use Rust Nightly

```
rustup toolchain install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup default nightly
```

functions accessible to WebAssmebly need to be marked with #[no_mangle]

## Using NPM

```
npm install
// build project
npm run build
// run project
npm run start
```

## Getting WASM
```
// es7 async await
(
async () => {

let importObject;
const res = await fetch('wasm_test.wasm');
const bytes = await res.arrayBuffer();
const results = await WebAssembly.instantiate(bytes, importObject);

const {add, subtract, loop_add} = results.instance.exports;
}
)();
```