pcbjam/tests/collab/build.mjs
2026-06-10 17:37:58 +02:00

25 lines
1.1 KiB
JavaScript

// Bundle the collab browser entry (reconciler + Yjs + BroadcastChannel transport,
// sourced from the web frontend) into a single IIFE the pl_editor harness loads.
// nodePaths lets esbuild resolve `yjs` from tests/node_modules even though the
// reconciler lives under web/. Output: apps/kicad/collab-bundle.js (global KicadCollab).
import { build } from "esbuild";
import path from "node:path";
import { fileURLToPath } from "node:url";
const testsDir = path.resolve(fileURLToPath(new URL("..", import.meta.url)));
await build({
entryPoints: [path.join(testsDir, "collab/browser-entry.ts")],
bundle: true,
format: "iife",
outfile: path.join(testsDir, "apps/kicad/collab-bundle.js"),
nodePaths: [path.join(testsDir, "node_modules")],
// The e2e harness only exercises the BroadcastChannel transport; the server
// providers are reached via dynamic import() that never runs in tests, and
// their packages are only installed in the web/ pnpm workspace.
external: ["y-partyserver/provider", "@hocuspocus/provider"],
logLevel: "info",
target: "es2020",
});
console.log("collab bundle built → apps/kicad/collab-bundle.js");