Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grafbase/getting-started-with-rust-wasm
Rust ➡ WebAssembly for Webpack, Node.js and Deno
https://github.com/grafbase/getting-started-with-rust-wasm
blog deno educational-project javascript js nodejs rust rust-lang template ts typescript wasm wasm-bindgen wasm-pack webassembly webpack
Last synced: 3 months ago
JSON representation
Rust ➡ WebAssembly for Webpack, Node.js and Deno
- Host: GitHub
- URL: https://github.com/grafbase/getting-started-with-rust-wasm
- Owner: grafbase
- License: apache-2.0
- Created: 2023-07-05T12:24:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-15T02:44:36.000Z (about 1 year ago)
- Last Synced: 2024-04-13T04:20:49.171Z (10 months ago)
- Topics: blog, deno, educational-project, javascript, js, nodejs, rust, rust-lang, template, ts, typescript, wasm, wasm-bindgen, wasm-pack, webassembly, webpack
- Language: Nix
- Homepage: https://grafbase.com/blog/getting-started-with-rust-and-webassembly
- Size: 53.7 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Getting Started With Rust and WebAssembly
Rust ➡ WebAssembly for Webpack, Node.js and Deno
See Getting started with Rust and WebAssembly# Try It Out
# Setup
## Webpack
- [Install Rust](https://www.rust-lang.org/learn/get-started)
- [Install Node.js](https://nodejs.org/)
- [Install `wasm-pack`](https://rustwasm.github.io/wasm-pack/installer/)
- Run `npm install`## Node.js
- [Install Rust](https://www.rust-lang.org/learn/get-started)
- [Install Node.js](https://nodejs.org/)
- [Install `wasm-pack`](https://rustwasm.github.io/wasm-pack/installer/)
- Alternatively, [install `cargo-make`](https://github.com/sagiegurari/cargo-make#installation)## Deno
- [Install Rust](https://www.rust-lang.org/learn/get-started)
- [Install Node.js](https://nodejs.org/)
- [Install `cargo-make`](https://github.com/sagiegurari/cargo-make#installation)## With Nix
1. [Install Nix](https://nixos.org/download.html)
2. [Activate Flakes](https://nixos.wiki/wiki/Flakes)
3. [Install direnv](https://direnv.net/)
4. [Install nix-direnv](https://github.com/nix-community/nix-direnv)
5. Add the following `.envrc` file:```sh
use flake # activates the flake
dotenv_if_exists .env # optionally loads a .env file if it exists
```6. Run `direnv allow .` inside the project directory to allow Direnv to execute the `.envrc`
7. For Webpack, also run `npm install`# Usage
## Node.js
### With `wasm-pack`
1. `wasm-pack build --target nodejs` - Builds and generates bindings for `src/lib.rs`
2. `node src/node.mjs` - Runs `src/node.mjs`### With `cargo-make`
- `cargo make run-node` - Runs `src/node.mjs`
## Webpack
1. `npm run serve`
2. Open [http://localhost:8080](http://localhost:8080/)## Deno
- `cargo make run-deno` - Runs `src/deno.ts`