From 269449da465a4d55a5cb2c90cb2ff453c478201c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20T=C3=B6rcsv=C3=A1ri?= Date: Tue, 30 Jun 2026 09:30:15 +0200 Subject: [PATCH] fix(collab): dedupe yjs so @pcbjam/shared + standalone link ONE instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two pnpm workspaces (root globs pcbjam-shared; pcbjam/web has it too) each install yjs, so shared's collab code (kicad-y) and the app's yjs were two physical copies → a Y.Map rejects the other instance's Y types ('Unexpected content type'). resolve.dedupe:['yjs'] in vite + vitest forces a single copy. Not a test-only artifact: the same two copies bundle into the editor and would break collab on doc seed. Full standalone suite now 55/55 (was 47/55). Co-Authored-By: Claude Opus 4.8 (1M context) --- web/standalone/vite.config.ts | 5 +++++ web/standalone/vitest.config.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/web/standalone/vite.config.ts b/web/standalone/vite.config.ts index 701d5a8..306652b 100644 --- a/web/standalone/vite.config.ts +++ b/web/standalone/vite.config.ts @@ -40,6 +40,11 @@ export default defineConfig({ alias: { "@": path.resolve(__dirname, "./src"), }, + // @pcbjam/shared is in a second pnpm workspace with its own `yjs`; dedupe so + // the bundled editor links ONE yjs (a mutable, instanceof-checked singleton). + // Without it shared's collab code (kicad-y) and the app's yjs are two + // instances → "Unexpected content type" the moment a doc is seeded. + dedupe: ["yjs"], }, server: { // Default :3048. The closed `pnpm dev:gpl` runs a second editor instance on diff --git a/web/standalone/vitest.config.ts b/web/standalone/vitest.config.ts index 62549f3..968f811 100644 --- a/web/standalone/vitest.config.ts +++ b/web/standalone/vitest.config.ts @@ -7,6 +7,11 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ resolve: { alias: { "@": path.resolve(__dirname, "./src") }, + // @pcbjam/shared lives in a second pnpm workspace, so without this its `yjs` + // and the standalone's `yjs` resolve to two physical copies → a Y.Map from + // one instance rejects Y types from the other ("Unexpected content type"). + // Force a single yjs (it's a shared mutable singleton — instanceof-checked). + dedupe: ["yjs"], }, test: { environment: "node",