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.
$ browserify -t rustify index.js > bundle.js
// index.js
var rust = require('rustify')
var wasm = rust`
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
`
WebAssembly.instantiate(wasm, {})
.then(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)
})
var rust = require('rustify')
var wasm = rust('./add-one.rs')
WebAssembly.instantiate(wasm, {})
.then(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#stringCreate an inline rust template string to a Uint8Array, ready to be passed to
the WASM constructor.
With rustup installed:
$ rustup update nightly
$ rustup target add wasm32-unknown-unknown --toolchain nightly
$ cargo install --git https://github.com/alexcrichton/wasm-gc
$ npm install rustify
Overall
Maintained
Code review
npm
Latest release
Releases this year
7,487 followers · starred Nov 2017
1,570 followers · starred Nov 2017
458 followers · starred Dec 2017
583 followers · starred Apr 2018
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.
$ browserify -t rustify index.js > bundle.js
// index.js
var rust = require('rustify')
var wasm = rust`
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
`
WebAssembly.instantiate(wasm, {})
.then(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)
})
var rust = require('rustify')
var wasm = rust('./add-one.rs')
WebAssembly.instantiate(wasm, {})
.then(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#stringCreate an inline rust template string to a Uint8Array, ready to be passed to
the WASM constructor.
With rustup installed:
$ rustup update nightly
$ rustup target add wasm32-unknown-unknown --toolchain nightly
$ cargo install --git https://github.com/alexcrichton/wasm-gc
$ npm install rustify
Overall
Maintained
Code review
npm
Latest release
Releases this year
7,487 followers · starred Nov 2017
1,570 followers · starred Nov 2017
458 followers · starred Dec 2017
583 followers · starred Apr 2018