browserify/rustify

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

Homepage:

Size: 43

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rustify

npm version build status downloads js-standard-style

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.

Usage
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)

External
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)

API
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.

Installation

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
License

Apache-2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.