Replace platform-specific optionalDependencies with bun devDependency#518
Merged
ochafik merged 2 commits intomodelcontextprotocol:mainfrom Mar 6, 2026
Conversation
Fixes modelcontextprotocol#222. The bun meta-package handles platform detection internally. Rollup resolves its own platform binaries transitively. Removes ~400MB of bloat for SDK consumers. Simplifies setup-bun.mjs accordingly.
No longer needed since the bun npm package handles binary installation and PATH registration automatically.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #222
Replaces the 17 platform-specific
optionalDependencies(@oven/bun-*,@rollup/rollup-*) with a singlebundevDependency, and removessetup-bun.mjsentirely.Builds on the investigation from #451, thanks @ochafik!
Context
At Datadog we're building on MCP Apps and this
optionalDependenciesbloat (~400MB of platform binaries) is blocking our CI pipelines, which motivated picking this up.Problem
The repo listed 11
@oven/bun-*and 6@rollup/rollup-*platform-specific packages inoptionalDependencies. npm'soptionalDependenciesare installed for all consumers (they're "optional" in that npm doesn't fail if installation fails, not that they're skipped). This caused ~400MB of unnecessary downloads for anyone installing the SDK.Why the previous approaches don't work
devDependencies(Move Bun and Rollup binaries to devDependencies and skip setup when installed as dependency #451): these packages declareos/cpuconstraints — npm silently skips mismatches inoptionalDependenciesbut fails hard indevDependencies(npm cion macOS ARM errors on@oven/bun-linux-x64)prepareruns for the build stepApproach
Instead of working around the problem, fix the root cause — the dependencies were declared at the wrong level:
@rollup/rollup-*— remove themThe SDK build uses bun (
build.bun.ts), not rollup. These entries were added in556a857fas a workaround for an npm bug where rollup's nestedoptionalDependenciesweren't being fetched for the example workspaces (which use vite).Verified that
@rollup/rollup-darwin-arm64now resolves correctly via vite without the top-level entries (tested with npm 10.9.2). If the bug resurfaces on older npm versions, contributors would see example build failures — the fix is simply to update npm. This only affects example workspace builds, not the SDK itself.@oven/bun-*— replace with"bun": "^1.2.21"indevDependenciesThe
bunnpm meta-package handles platform detection internally (via its own scopedoptionalDependencies) and registers the binary innode_modules/.bin/bunautomatically. As adevDependency, it's only installed for contributors, never for consumers.Remove
setup-bun.mjsThis script existed because the raw
@oven/bun-*platform packages don't have abinfield — they just contain the binary file. The script had to manually detect the platform, find the right package innode_modules/@oven/bun-*, and symlink the binary to.bin/bun. With thebunmeta-package, all of that is handled automatically by npm. The script is no longer needed.Remove
postinstall, simplifyprepareBased on this comment #451 (review) from @jonathanhefner.
postinstall(node scripts/setup-bun.mjs || ...) was redundant withpreparewhich already ran the same script, andsetup-bun.mjswasn't even shipped in the published package ("files": ["dist"])preparesimplified from"node scripts/setup-bun.mjs && npm run build && husky"to"npm run build && husky"Test plan
Verified from a clean state (
rm -rf node_modules && npm ci):npm cisucceedsnpm run build/npm run build:allsucceednpm testpasses (85/85)npm run test:e2epassesnpm run prettierpassestypedocpassesnpm packproduces a tarball with nooptionalDependencies@rollup/rollup-darwin-arm64resolves correctly via vite without top-level entries (npm 10.9.2)@oven/bun-*or@rollup/rollup-*