mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
use workers-gen-go command in hello example
This commit is contained in:
parent
1127e6bba3
commit
496d28e86a
2
examples/hello/.gitignore
vendored
2
examples/hello/.gitignore
vendored
@ -1 +1 @@
|
|||||||
dist
|
build
|
@ -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:
|
||||||
|
@ -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 });
|
|
||||||
}
|
|
||||||
}
|
|
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user