// Bundles the runtime MyGo injects into every page into // internal/bridge/bridge.js, which the Go package embeds, and the script // WebView2's web views in native UI run in an isolated world into // internal/windows/keys.js. The output is committed, so Go users never // need Bun. import { join } from "node:path"; const outputs: [entry: string, out: string][] = [ ["src/bridge.ts", "../../internal/bridge/bridge.js"], ["src/keys-world.ts", "../../internal/windows/keys.js"], ]; for (const [entry, file] of outputs) { const out = join(import.meta.dir, file); const result = await Bun.build({ entrypoints: [join(import.meta.dir, entry)], format: "iife", target: "browser", minify: true, }); if (!result.success) { for (const log of result.logs) console.error(log); process.exit(1); } const code = (await result.outputs[0]!.text()).trim(); await Bun.write(out, "// Code generated by `bun run build` from packages/bridge. DO NOT EDIT.\n" + code + "\n"); console.log(`wrote ${out} (${code.length} bytes)`); }