The generated script from wrangler keeps re-instantiating the WASM module every time the request is processed. Instead, let's switch to using the much, much better Webpack support for WASM.master
parent
e562a8d7e4
commit
c91d152d65
@ -1,39 +0,0 @@
|
||||
# 👷♀️🦀🕸️ `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
|
||||
```
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "paprika",
|
||||
"version": "0.1.0",
|
||||
"description": "A simple blog integrated with Standard Notes and running on Cloudflare Workers",
|
||||
"main": "worker.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/PeterCxy/paprika.git"
|
||||
},
|
||||
"author": "PeterCxy",
|
||||
"license": "WTFPL",
|
||||
"bugs": {
|
||||
"url": "https://github.com/PeterCxy/paprika/issues"
|
||||
},
|
||||
"homepage": "https://github.com/PeterCxy/paprika#readme",
|
||||
"devDependencies": {
|
||||
"@wasm-tool/wasm-pack-plugin": "^1.2.0",
|
||||
"webpack": "^4.42.1"
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
||||
|
||||
module.exports = {
|
||||
target: "webworker",
|
||||
entry: "./worker.js",
|
||||
mode: "production",
|
||||
plugins: [
|
||||
new WasmPackPlugin({
|
||||
crateDirectory: __dirname,
|
||||
})
|
||||
]
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"body_part": "script",
|
||||
"bindings": [
|
||||
{
|
||||
"name": "wasm",
|
||||
"type": "wasm_module",
|
||||
"part": "wasmprogram"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in new issue