mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 01:39:11 +00:00
23 lines
481 B
JavaScript
23 lines
481 B
JavaScript
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 });
|
|
}
|
|
}
|