Here’s a (rare) working example for WASM
on Firebase Cloud Function
(NodeJS
) with wasm-bindgen
. It should be a good starter for ordinary NodeJS
target too.
WASM on Firebase
Cloud FunctionTLDR;
Initialize
# Setup Firebase
npm install -g firebase-tools
firebase init
firebase login# Setup Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh# Setup Cargo
cargo install cargo-watch# Setup WASM
cargo install -f wasm-bindgen-cli
Develop
# To watch and build WASM from Rust
cd wasm
cargo watch -- . ./dev.sh# To run WASM with Firebase
cd functions
npm run dev
Done!
And yes! I’m now in love withRust
and WebAssembly
So much fun! :)
Debugging somehow easier for each release but it keep breaking my deprecated/outdated setup so I decide to make minimal working one.
FYI: Here’s outdated 2016 version and no TypeScript (skip this)
TLDR: And here’s 2021 version (use this)
Example
Setup
yarn
Debug
Hit
F5
to start debugging
And that’s it! It’s mean to be minimal as possible, Happy Coding!