From 496d28e86ae8afca03a7d9e37f7bd7b4b7befeaa Mon Sep 17 00:00:00 2001 From: syumai Date: Sat, 29 Apr 2023 17:38:39 +0900 Subject: [PATCH] use workers-gen-go command in hello example --- examples/hello/.gitignore | 2 +- examples/hello/Makefile | 4 ++-- examples/hello/worker.mjs | 22 ---------------------- examples/hello/wrangler.toml | 2 +- 4 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 examples/hello/worker.mjs diff --git a/examples/hello/.gitignore b/examples/hello/.gitignore index 53c37a1..c795b05 100644 --- a/examples/hello/.gitignore +++ b/examples/hello/.gitignore @@ -1 +1 @@ -dist \ No newline at end of file +build \ No newline at end of file diff --git a/examples/hello/Makefile b/examples/hello/Makefile index 320ddc3..ecb5843 100644 --- a/examples/hello/Makefile +++ b/examples/hello/Makefile @@ -4,8 +4,8 @@ dev: .PHONY: build build: - mkdir -p dist - tinygo build -o ./dist/app.wasm -target wasm ./... + go run ../../cmd/workers-gen-go + tinygo build -o ./build/app.wasm -target wasm ./... .PHONY: publish publish: diff --git a/examples/hello/worker.mjs b/examples/hello/worker.mjs deleted file mode 100644 index 649ccf0..0000000 --- a/examples/hello/worker.mjs +++ /dev/null @@ -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 }); - } -} diff --git a/examples/hello/wrangler.toml b/examples/hello/wrangler.toml index 32eaddf..60d2b45 100644 --- a/examples/hello/wrangler.toml +++ b/examples/hello/wrangler.toml @@ -1,5 +1,5 @@ name = "hello" -main = "./worker.mjs" +main = "./build/worker.mjs" compatibility_date = "2022-05-13" compatibility_flags = [ "streams_enable_constructors"