JavaScript to WebAssembly toolchain
The intent for this tool is to provide a means to write PureScript, compile to JavaScript, and package as a self-contained Wasi command.
Ensure Rust stable is installed.
rustup install stable && rustup default stable
Add the wasm32-wasi target.
rustup target add wasm32-wasi
From the root of the js2wasm
project, download the wasi sdk.
./download-wasi-sdk.sh
Set the QuickJS Wasi SDK environment variable.
export QUICKJS_WASM_SYS_WASI_SDK_PATH=$(pwd)/wasi-sdk
Alternatively, direnv
can be used to set the above automatically. See the .envrc file.
direnv allow .
Invoke the default make target.
make
Note: this project has only been built on Ubuntu LTS 22.04 w/ the clang development package installed.
target/release/js2wasm
error: The following required arguments were not provided:
<input>
USAGE:
js2wasm <input> -o <output>
Where <input>
is a JavaScript command file and <output>
is a Wasm file name. For example:
js2wasm index.js -o index.wasm
See the example
dir under the root of this project.
- Ensure build works on OSX.
- Add config options for optimization of code size / speed.
The code in the repo was adaptated from Javy with the following changes:
- Change naming, make company agnostic (i.e. Shopify -> Cmd).
- Remove hard-coded Wasm optimization (can be done later with
wasm-opt
). - Reference quickjs-wasm-rs as a lib from crates.io.