mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-23 03:35:38 +00:00
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]>
20 lines
742 B
TypeScript
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",
|
|
};
|
|
},
|
|
};
|