Skip to content

Remove dev-only platform binaries from optionalDependencies#517

Closed
gh0stonio wants to merge 1 commit intomodelcontextprotocol:mainfrom
gh0stonio:antoine.leveque/fix-optional-deps-222-v2
Closed

Remove dev-only platform binaries from optionalDependencies#517
gh0stonio wants to merge 1 commit intomodelcontextprotocol:mainfrom
gh0stonio:antoine.leveque/fix-optional-deps-222-v2

Conversation

@gh0stonio
Copy link
Contributor

@gh0stonio gh0stonio commented Mar 3, 2026

Summary

Fixes #222, removes @oven/bun-* and @rollup/rollup-* from optionalDependencies entirely, and removes the redundant postinstall script.

Builds on the investigation from #451, thanks @ochafik! This is a simpler alternative to #516.

Context

At Datadog we're building on MCP Apps and this optionalDependencies bloat (~400MB of platform binaries) is blocking our CI pipelines, which motivated picking this up.

Why #451's approach doesn't work

#451 moved the platform binaries from optionalDependencies to devDependencies. These packages declare os/cpu constraints in their own package.json, npm silently skips mismatches in optionalDependencies but fails hard in devDependencies (e.g. npm ci on macOS ARM errors on @oven/bun-linux-x64).

Approach

Instead of moving deps around, just remove them — they're not needed:

  • @rollup/rollup-*: rollup already declares its own platform-specific optionalDependencies, npm resolves them transitively, the top-level entries are redundant
  • @oven/bun-*: setup-bun.mjs (run by prepare) already gracefully handles missing binaries with a "install bun separately" fallback. Contributors who need bun can install it globally via bun.sh
  • Removed postinstall: redundant with prepare (which already runs setup-bun.mjs), and the script isn't even shipped in the published package ("files": ["dist"])

Test plan

  • npm ci succeeds
  • npm run build succeeds
  • npm pack — published package.json contains no optionalDependencies

…ostinstall

Fixes modelcontextprotocol#222. Rollup resolves its own platform binaries transitively.
Bun setup script already handles missing binaries gracefully. The
postinstall script is redundant with prepare.
@gh0stonio
Copy link
Contributor Author

Alternative to #516 which takes a prepack/postpack approach to strip the entries at publish time instead of removing them entirely.

@gh0stonio gh0stonio marked this pull request as ready for review March 3, 2026 12:26
@gh0stonio gh0stonio marked this pull request as draft March 3, 2026 13:01
@gh0stonio
Copy link
Contributor Author

Closing in favor of #516. This approach (removing optionalDependencies entirely) breaks contributor DX since bun setup relies on them being installed before prepare runs.

@gh0stonio gh0stonio closed this Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(optional)Dependencies on Bun and Rollup adds 400+ MB to the install size

1 participant