This page assumes you are using a Mac with the M1 chip and want to compile a custom version of the Saito WASM library and have it used by a locally-compiled version of Saito Javascript. If you are trying to compile Saito on another OS please see our standard installation guide.
NOTE: unless you know why you are doing this you probably don't need to do it at all! Our Saito Javascript repository (saito-lite-rust) comes bundled with a pre-compiled version of the WASM saito-js library included its package.json and will work without the need to compile or link anything locally. These steps are only necessary if you want to modify the Rust/Javascript code or debug core parts of the software from within javascript.
Before starting, ensure:
nodeJS and npm are installed.
homebrew is installed - install
you have the saito-lite-rust, and saito-rust-workspace repositories cloned on your local machine and are capable of compiling them.
brew install llvm
export CC=/opt/homebrew/opt/llvm/bin/clang
cd saito-rust-workspace/saito-wasm
npm i -g wasm-pack
CC=/opt/homebrew/opt/llvm/bin/clang AR=/opt/homebrew/opt/llvm/bin/llvm-ar wasm-pack build --target web --out-dir wasm_build/deps/pkg/
npm install
npm run build
npm link
cd saito-rust-workspace/saito-js
npm install
npm link saito-wasm
npm run build
cd dist
npm link
cd saito-lite-rust
npm install
npm link saito-js
npm run go