Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 869 Bytes

File metadata and controls

19 lines (13 loc) · 869 Bytes

miniprogram-rust-wasm-example

An example code for embeding rust code into WeChat MiniProgram

Instruction

Required tools:

Compilation:

  1. The rust-mod dir is a rust project. Compile it with wasm-pack build . The compiled code is in rust-mod/pkg .
  2. Put Compile the wasm code rust-mod/pkg/rust_mod_bg.wasm into js code with wasm2js : wasm2js -o pkg/rust_mod_bg.wasm.js pkg/rust_mod_bg.wasm
  3. Inject polyfill: prepend import { TextDecoder, TextEncoder } from '../../polyfill'; to pkg/rust_mod.js
  4. Inject polyfill: prepend import { atob } from '../../polyfill'; to pkg/rust_mod_bg.wasm.js
  5. Run in WeChat developer tools now!