Example repo for synthrs integration with WebAssembly (via Rust) and TypeScript (using jsapp-boilerplate). Works with Firefox, Chrome, Safari, and Edge.
- For the Rust code: see
src/wasm/src/lib.rs
- For the JS/TS glue: see
src/components/App/App.tsx
- For synthrs: see the synthrs GitHub repository
- Add
target: "esnext"
totsconfig.json
yarn add --dev @babel/plugin-syntax-dynamic-import
- Add
@babel/plugin-syntax-dynamic-import
to webpack babel plugins, yarn dev dependencies - Add
.wasm
to webpack resolve - Disable
split-chunk-plugins
in webpackoptimize
- For MSEdge, add
webpack.ProvidePlugin
forTextDecoder
andTextEncoder
(see this), and thetext-encoding
polyfill to dependencies
$ yarn install
$ yarn d
$ yarn install
$ yarn clean && yarn build:github
$ yarn deploy:github:prebuilt
$ rustup default nightly
$ rustup target add wasm32-unknown-unknown
$ cargo +nightly install wasm-bindgen-cli
$ cargo +nightly build --target wasm32-unknown-unknown --release
$ wasm-bindgen target/wasm32-unknown-unknown/release/synthrs_wasm.wasm --out-dir bindgen
A compressed .gz
is ok, but make sure the Content-Type
header of the .wasm is application/wasm
, or it will fail to load.