40 lines
1.1 KiB
Markdown
40 lines
1.1 KiB
Markdown
# 👷♀️🦀🕸️ `rustwasm-worker-template`
|
|
|
|
A template for kick starting a Cloudflare worker project using
|
|
[`wasm-pack`](https://github.com/rustwasm/wasm-pack).
|
|
|
|
This template is designed for compiling Rust libraries into WebAssembly and
|
|
publishing the resulting worker to Cloudflare's worker infrastructure.
|
|
|
|
## 🔋 Batteries Included
|
|
|
|
* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
|
|
between WebAssembly and JavaScript.
|
|
* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
|
|
for logging panic messages to the developer console.
|
|
* [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
|
|
for small code size.
|
|
|
|
## 🚴 Usage
|
|
|
|
### 🐑 Use `wrangler generate` to Clone this Template
|
|
|
|
[Learn more about `wrangler generate` here.](https://github.com/cloudflare/wrangler)
|
|
|
|
```
|
|
wrangler generate wasm-worker https://github.com/cloudflare/rustwasm-worker-template.git
|
|
cd wasm-worker
|
|
```
|
|
|
|
### 🛠️ Build with `wasm-pack build`
|
|
|
|
```
|
|
wasm-pack build
|
|
```
|
|
|
|
### 🔬 Test in Headless Browsers with `wasm-pack test`
|
|
|
|
```
|
|
wasm-pack test --headless --firefox
|
|
```
|