Merge branch 'main' into add-workers-gen-go-command

This commit is contained in:
syumai 2023-04-30 00:25:05 +09:00
commit 9895c004f4
12 changed files with 57 additions and 209 deletions

24
examples/assets/shim.mjs Normal file
View 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 });
}

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }

View File

@ -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 }