mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
Merge branch 'main' into add-workers-gen-go-command
This commit is contained in:
commit
9895c004f4
24
examples/assets/shim.mjs
Normal file
24
examples/assets/shim.mjs
Normal file
@ -0,0 +1,24 @@
|
||||
import "./polyfill_performance.js";
|
||||
import "./wasm_exec.js";
|
||||
|
||||
const go = new Go();
|
||||
|
||||
let mod;
|
||||
|
||||
export function init(m) {
|
||||
mod = m;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const readyPromise = new Promise((resolve) => {
|
||||
globalThis.ready = resolve;
|
||||
});
|
||||
const instance = new WebAssembly.Instance(mod, go.importObject);
|
||||
go.run(instance);
|
||||
await readyPromise;
|
||||
}
|
||||
|
||||
export async function fetch(req, env, ctx) {
|
||||
await run();
|
||||
return handleRequest(req, { env, ctx });
|
||||
}
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
22
examples/cache/worker.mjs
vendored
22
examples/cache/worker.mjs
vendored
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,25 +1,9 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
||||
// Durable Object
|
||||
|
||||
|
22
examples/env/worker.mjs
vendored
22
examples/env/worker.mjs
vendored
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
@ -1,22 +1,6 @@
|
||||
import "../assets/polyfill_performance.js";
|
||||
import "../assets/wasm_exec.js";
|
||||
import * as imports from "../assets/shim.mjs";
|
||||
import mod from "./dist/app.wasm";
|
||||
|
||||
const go = new Go();
|
||||
imports.init(mod);
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
export default { fetch: imports.fetch }
|
||||
|
Loading…
x
Reference in New Issue
Block a user