From 4191a4b6e637d51c308a4a317fb03db33379beeb Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 13:58:29 +0000 Subject: [PATCH] fix(core): load child_process normally in the git checkout reader readGitCheckout loaded node:child_process through require(), which does not exist in the ESM API runtime. Linking a project space to a folder that is a git checkout therefore failed after the space was created. The lazy load is no longer needed: the reader is only reachable through the server-only "@rakazo/core/git-checkout" subpath, never through the package entry the web app bundles. Import spawn at the top instead. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u --- packages/core/src/git-checkout.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/core/src/git-checkout.ts b/packages/core/src/git-checkout.ts index ccf1ff7..899d2ac 100644 --- a/packages/core/src/git-checkout.ts +++ b/packages/core/src/git-checkout.ts @@ -1,19 +1,10 @@ +// Server only: reached through the "@rakazo/core/git-checkout" subpath, never the browser entry. +import { spawn } from "node:child_process"; import { access } from "node:fs/promises"; import path from "node:path"; import { gitStatusArgv, gitUntrackedFilesArgv, parseGitNameOnly } from "./compose-update.js"; import { DEFAULT_UPDATE_REMOTE, parseGitStatusPorcelain } from "./self-update.js"; -// Lazy import to avoid bundling `node:child_process` in browser bundles. -// `defaultGitRunner` is server-only; lazy-loading ensures tree-shaking works. -type SpawnFn = typeof import("node:child_process").spawn; -let _spawn: SpawnFn | undefined; -const getSpawn = (): SpawnFn => { - if (_spawn === undefined) { - _spawn = require("node:child_process").spawn as SpawnFn; - } - return _spawn; -}; - export interface GitCheckoutStatus { present: boolean; remoteUrl: string | null; @@ -32,7 +23,6 @@ export type GitRunner = (args: string[], cwd: string) => Promise { return new Promise((resolve) => { - const spawn = getSpawn(); const child = spawn("git", args, { cwd, env: process.env }); let output = ""; child.stdout.on("data", (chunk: Buffer | string) => {