This repository demonstrates how to integrate Rust and Node.js using WebAssembly.
- rust/: Contains the Rust code.
- node/: Contains the Node.js code that uses the WebAssembly module generated from the Rust code.
-
Navigate to the
rust
directory:cd rust
-
Build the Rust project using wasm-pack:
wasm-pack build --target nodejs
-
Copy the pkg directory to the node directory.
cp -r pkg ../node/
-
Navigate to the
node
directory:cd ../node
-
Build the Rust project using wasm-pack:
npm install
-
Run the Node.js script:
ts-node ./index.ts