From 11f59a2ae091edc3638703c6a8acc06bc87e943a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Feb 2026 17:59:21 +0000 Subject: [PATCH] fix: move bun/rollup binaries from optionalDependencies to devDependencies Fixes #222. The @oven/bun-* and @rollup/rollup-* binaries were listed as optionalDependencies, causing npm to download 400MB+ of platform-specific binaries when consumers installed the package. These are build tools only needed by contributors, not SDK consumers. Changes: - Move all @oven/bun-* and @rollup/rollup-* packages from optionalDependencies to devDependencies so they're not installed for SDK consumers - Guard setup-bun.mjs postinstall script with INIT_CWD check to skip execution when running as an installed dependency (not in the repo itself) https://claude.ai/code/session_01YXG43Kz9LuxBygzicH1LcZ --- package.json | 36 +++++++++++++++++------------------- scripts/setup-bun.mjs | 14 ++++++++++---- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 221d428ec..1e4e60150 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,24 @@ "devDependencies": { "@boneskull/typedoc-plugin-mermaid": "^0.2.0", "@modelcontextprotocol/sdk": "1.25.2", + "@oven/bun-darwin-aarch64": "^1.2.21", + "@oven/bun-darwin-x64": "^1.2.21", + "@oven/bun-darwin-x64-baseline": "^1.2.21", + "@oven/bun-linux-aarch64": "^1.2.21", + "@oven/bun-linux-aarch64-musl": "^1.2.21", + "@oven/bun-linux-x64": "^1.2.21", + "@oven/bun-linux-x64-baseline": "^1.2.21", + "@oven/bun-linux-x64-musl": "^1.2.21", + "@oven/bun-linux-x64-musl-baseline": "^1.2.21", + "@oven/bun-windows-x64": "^1.2.21", + "@oven/bun-windows-x64-baseline": "^1.2.21", "@playwright/test": "1.57.0", + "@rollup/rollup-darwin-arm64": "^4.53.3", + "@rollup/rollup-darwin-x64": "^4.53.3", + "@rollup/rollup-linux-arm64-gnu": "^4.53.3", + "@rollup/rollup-linux-x64-gnu": "^4.53.3", + "@rollup/rollup-win32-arm64-msvc": "^4.53.3", + "@rollup/rollup-win32-x64-msvc": "^4.53.3", "@types/bun": "^1.3.2", "@types/react": "^19.2.2", "@types/react-dom": "^19.2.2", @@ -117,25 +134,6 @@ "optional": true } }, - "optionalDependencies": { - "@oven/bun-darwin-aarch64": "^1.2.21", - "@oven/bun-darwin-x64": "^1.2.21", - "@oven/bun-darwin-x64-baseline": "^1.2.21", - "@oven/bun-linux-aarch64": "^1.2.21", - "@oven/bun-linux-aarch64-musl": "^1.2.21", - "@oven/bun-linux-x64": "^1.2.21", - "@oven/bun-linux-x64-baseline": "^1.2.21", - "@oven/bun-linux-x64-musl": "^1.2.21", - "@oven/bun-linux-x64-musl-baseline": "^1.2.21", - "@oven/bun-windows-x64": "^1.2.21", - "@oven/bun-windows-x64-baseline": "^1.2.21", - "@rollup/rollup-darwin-arm64": "^4.53.3", - "@rollup/rollup-darwin-x64": "^4.53.3", - "@rollup/rollup-linux-arm64-gnu": "^4.53.3", - "@rollup/rollup-linux-x64-gnu": "^4.53.3", - "@rollup/rollup-win32-arm64-msvc": "^4.53.3", - "@rollup/rollup-win32-x64-msvc": "^4.53.3" - }, "overrides": { "seroval": "1.4.1", "seroval-plugins": "1.4.2", diff --git a/scripts/setup-bun.mjs b/scripts/setup-bun.mjs index 3314cacca..5ea211cff 100644 --- a/scripts/setup-bun.mjs +++ b/scripts/setup-bun.mjs @@ -1,7 +1,4 @@ #!/usr/bin/env node -// Immediate log to verify script execution -console.log("[setup-bun] Script loaded"); - /** * Postinstall script to set up bun from platform-specific optional dependencies. * Handles Windows ARM64 by downloading x64-baseline via emulation. @@ -16,7 +13,7 @@ import { writeFileSync, statSync, } from "fs"; -import { join, dirname } from "path"; +import { join, dirname, resolve } from "path"; import { spawnSync } from "child_process"; import { fileURLToPath } from "url"; import { get } from "https"; @@ -24,6 +21,15 @@ import { createGunzip } from "zlib"; const __dirname = dirname(fileURLToPath(import.meta.url)); const projectRoot = join(__dirname, ".."); + +// Skip when installed as a dependency (INIT_CWD is the user's project directory, +// not the package root). Bun is a dev-only build tool not needed by SDK consumers. +if (process.env.INIT_CWD && resolve(process.env.INIT_CWD) !== resolve(projectRoot)) { + process.exit(0); +} + +// Immediate log to verify script execution +console.log("[setup-bun] Script loaded"); const nodeModules = join(projectRoot, "node_modules"); const binDir = join(nodeModules, ".bin");