Files
dev/scripts/lib/dev-wasm-plugin.ts
zeekayandHanzo Dev f44b2255c3 Ship dev.wasm inside the server bundle
The pack build inlines the module in place of devWasmBytes.ts, so the
bundle, the single executable, the desktop app and hosted web carry it and
resolve no repo-relative path. A test builds DevWasm.ts with the real plugin,
moves the bundle where no repo is beside it, and decides.

Co-authored-by: Hanzo Dev <[email protected]>
2026-11-21 02:08:11 -08:00

20 lines
742 B
TypeScript

import * as NodeFS from "node:fs";
import * as NodePath from "node:path";
const repoRoot = NodePath.resolve(import.meta.dirname, "../..");
const sourceModule = NodePath.join(repoRoot, "apps/server/src/orchestration-v2/devWasmBytes.ts");
const wasmPath = NodePath.join(repoRoot, "go/dev.wasm");
/** Pack plugin: the bundle carries `dev.wasm` inline in place of `devWasmBytes.ts`. */
export const devWasmPlugin = {
name: "hanzodev:dev-wasm",
load(id: string) {
if (NodePath.resolve(id) !== sourceModule) return;
const base64 = NodeFS.readFileSync(wasmPath).toString("base64");
return {
code: `export const devWasmBytes = () => new Uint8Array(Buffer.from("${base64}", "base64"));`,
moduleType: "js",
};
},
};