diff --git a/scripts/coil/desktop-bundle-size.test.ts b/scripts/coil/desktop-bundle-size.test.ts index f5671914dfa..a55c73ce940 100644 --- a/scripts/coil/desktop-bundle-size.test.ts +++ b/scripts/coil/desktop-bundle-size.test.ts @@ -635,6 +635,20 @@ describe("verifyPackagedApp over a real asar", () => { }); }); + // The Bun-runtime variants are imported behind runtime detection the shipped app (always Node, + // via ELECTRON_RUN_AS_NODE) can never satisfy, and upstream's Windows sidecar deliberately omits + // them — their absence is not a break. Release run 31839839479 failed on exactly this. + it("does not require Bun-runtime-only packages the shipped app cannot load", () => { + withTempDir((dir) => { + const asarPath = writeAsar(dir, { + "apps/server/dist/bin.mjs": + 'import("@effect/platform-bun/BunHttpServer");import("@effect/sql-sqlite-bun/SqliteClient");', + "apps/desktop/dist-electron/main.cjs": "const x = 1;", + }); + assert.ok(verifyPackagedApp(asarPath).ok, "unreachable Bun-runtime imports are not breaks"); + }); + }); + // A packaging-topology change that hides a whole bundle directory must be an error, not an empty // green result — the pre-#102 gate verified only the Electron bundle on Windows and passed. it("fails when a first-party bundle directory is invisible to the checker", () => { diff --git a/scripts/coil/verify-desktop-bundle.mjs b/scripts/coil/verify-desktop-bundle.mjs index ee5bbfafa23..eec6298000a 100644 --- a/scripts/coil/verify-desktop-bundle.mjs +++ b/scripts/coil/verify-desktop-bundle.mjs @@ -72,6 +72,22 @@ export const FIRST_PARTY_BUNDLE_DIRS = ["apps/desktop/dist-electron", "apps/serv const RUNTIME_PROVIDED = new Set(["electron"]); const BUNDLED_WORKSPACE_PREFIXES = ["@t3tools/"]; +/* + * Imports the shipped app can never reach, so their absence is not a break. + * + * The server bundle imports these behind Bun-runtime detection (`typeof Bun !== "undefined"` in + * server.ts's HttpServerLive, `process.versions.bun !== undefined` in persistence/Layers/Sqlite.ts), + * and the shipped desktop app always runs the server under Node via ELECTRON_RUN_AS_NODE — the Bun + * branch cannot execute. Upstream agrees by construction: its Windows server.asar sidecar stages + * only the CLI's runtime external dependencies, which exclude both (that omission is what surfaced + * this list — release run 31839839479). The macOS artifact carries them incidentally, because its + * staging installs the full production dependency set. + * + * If the shipped server ever runs under Bun, this list is wrong and the failure is a MODULE_NOT_FOUND + * at startup on the Bun path — re-check both guard sites before growing or trusting it. + */ +const UNREACHABLE_IN_SHIPPED_RUNTIME = new Set(["@effect/platform-bun", "@effect/sql-sqlite-bun"]); + /** * @typedef {object} PackagedFile * @property {number} size @@ -219,6 +235,7 @@ export function isPackagedSpecifier(specifier) { const name = packageNameFromSpecifier(specifier); if (name === undefined) return false; if (RUNTIME_PROVIDED.has(name)) return false; + if (UNREACHABLE_IN_SHIPPED_RUNTIME.has(name)) return false; return !BUNDLED_WORKSPACE_PREFIXES.some((prefix) => name.startsWith(prefix)); }