Developers: Getting started building Rust + JavaScript hybrid apps for Node.js using the ssvmup
tool.
A one-stop tool for building Rust functions into WebAssembly (the Second State VM, or SSVM) and then accessing these functions from Node.js JavaScript.
From Linux command line
curl https://raw.githubusercontent.com/second-state/ssvmup/master/installer/init.sh -sSf | sh
From NPM and Node.js
npm i -g ssvmup
To build Rust functions for Node.js applications, use the following command. See a template application. The ssvmup compiles and generates the wasm file, and the corresponding JavaScript file to call wasm functions from JavaScript. If the rust package contains only binary crate(s) and there are no library crate, the build command will only generate the wasm(wasi) file for running with ssvm.
$ ssvmup build
In most cases, you will want to enable AOT optimization in order to improve performance.
$ ssvmup build --enable-aot
If you would like to use SSVM's extended WASI APIs including the Tensorflow WASI, enable the extensions. Make sure that you install the ssvm-extensions
NPM module in this case.
$ ssvmup build --enable-aot --enable-ext
To build Rust functions for Deno applications, use the following command. See a template application.
$ ssvmup build --target deno
By default, ssvmup will generate a directory for it's build output called pkg. If you'd like to customize this you can use the --out-dir flag.
$ ssvmup build --out-dir out
Use clean subcommand to remove pkg and target directories.
$ ssvmup clean
ssvmup
uses env_logger
to produce logs when ssvmup
runs.
To configure your log level, use the RUST_LOG
environment variable. For example:
RUST_LOG=info ssvmup build
This project is derived from the open source wasm-pack.