Name: rustify
Owner: browserify
Description: Rust WebAssembly transform for Browserify
Created: 2017-11-26 16:04:00.0
Updated: 2018-05-02 08:53:45.0
Pushed: 2018-02-21 15:51:26.0
Size: 43
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Rust WebAssembly transform for Browserify. Because this is an unstable rust feature, at the time of writing it relies on wasm-gc to be available from the command line. See Installation for instructions on how to install. Probably also doesn't work on Windows.
Because this feature is experimental in Rust, this module should be considered similarly.
owserify -t rustify index.js > bundle.js
ndex.js
rust = require('rustify')
wasm = rust`
no_mangle]
b fn add_one(x: i32) -> i32 {
x + 1
ssembly.instantiate(wasm, {})
hen(function (res) {
var addOne = res.instance.exports.add_one
console.log(addOne(41))
console.log(addOne(68))
.catch(function (e) {
console.error('Creating WASM module failed', e)
rust = require('rustify')
wasm = rust('./add-one.rs')
ssembly.instantiate(wasm, {})
hen(function (res) {
var addOne = res.instance.exports.add_one
console.log(addOne(41))
console.log(addOne(68))
.catch(function (e) {
console.error('Creating WASM module failed', e)
uint8Array = rust(filename)
Create a valid .rs
file to a Uint8Array
, ready to be passed to the WASM
constructor.
uint8Array = rust#string
Create an inline rust template string to a Uint8Array
, ready to be passed to
the WASM constructor.
With rustup installed:
stup update nightly
stup target add wasm32-unknown-unknown --toolchain nightly
rgo install --git https://github.com/alexcrichton/wasm-gc
m install rustify