use workers-gen-go command in hello example

This commit is contained in:
syumai 2023-04-29 17:38:39 +09:00
parent 1127e6bba3
commit 496d28e86a
4 changed files with 4 additions and 26 deletions

View File

@ -1 +1 @@
dist build

View File

@ -4,8 +4,8 @@ dev:
.PHONY: build .PHONY: build
build: build:
mkdir -p dist go run ../../cmd/workers-gen-go
tinygo build -o ./dist/app.wasm -target wasm ./... tinygo build -o ./build/app.wasm -target wasm ./...
.PHONY: publish .PHONY: publish
publish: publish:

View File

@ -1,22 +0,0 @@
import "../assets/polyfill_performance.js";
import "../assets/wasm_exec.js";
import mod from "./dist/app.wasm";
const go = new Go();
const readyPromise = new Promise((resolve) => {
globalThis.ready = resolve;
});
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
go.run(instance);
return instance;
});
export default {
async fetch(req, env, ctx) {
await load;
await readyPromise;
return handleRequest(req, { env, ctx });
}
}

View File

@ -1,5 +1,5 @@
name = "hello" name = "hello"
main = "./worker.mjs" main = "./build/worker.mjs"
compatibility_date = "2022-05-13" compatibility_date = "2022-05-13"
compatibility_flags = [ compatibility_flags = [
"streams_enable_constructors" "streams_enable_constructors"