MCPcopy Index your code
hub / github.com/browserify/rustify

github.com/browserify/rustify @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
17 symbols 22 edges 15 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
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

$ 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)
  })

External

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

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:

$ rustup update nightly
$ rustup target add wasm32-unknown-unknown --toolchain nightly
$ cargo install --git https://github.com/alexcrichton/wasm-gc
$ npm install rustify

License

Apache-2.0

Core symbols most depended-on inside this repo

handleCode
called by 2
lib/transform.js
extractTemplateNodes
called by 1
lib/transform.js
extractImportNodes
called by 1
lib/transform.js
rustify
called by 1
lib/rustify.js
instantiate
called by 1
test/syntax/main.js
rustify
called by 0
index.js
add_one
called by 0
example/add.rs
transform
called by 0
lib/transform.js

Shape

Function 17

Languages

TypeScript82%
Rust18%

Modules by API surface

lib/transform.js11 symbols
test/syntax/main.js1 symbols
test/syntax/extern.rs1 symbols
test/external/module.rs1 symbols
lib/rustify.js1 symbols
index.js1 symbols
example/add.rs1 symbols

For agents

$ claude mcp add rustify \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact