Skip to content

Move Bun and Rollup binaries to devDependencies and skip setup when installed as dependency#451

Open
ochafik wants to merge 1 commit intomainfrom
claude/fix-issue-222-Dp20q
Open

Move Bun and Rollup binaries to devDependencies and skip setup when installed as dependency#451
ochafik wants to merge 1 commit intomainfrom
claude/fix-issue-222-Dp20q

Conversation

@ochafik
Copy link
Contributor

@ochafik ochafik commented Feb 12, 2026

Summary

This PR moves Bun and Rollup platform-specific binaries from optionalDependencies to devDependencies, and adds logic to skip the Bun setup script when the package is installed as a dependency in another project.

Fixes #222

Key Changes

  • Dependency reorganization: Moved all @oven/bun-* and @rollup/rollup-* packages from optionalDependencies to devDependencies
  • Setup script enhancement: Added environment variable check in setup-bun.mjs to detect when the package is installed as a dependency (via INIT_CWD) and skip setup in those cases
  • Code cleanup: Removed debug logging statement and reorganized imports to include resolve from the path module

Implementation Details

The setup script now checks if INIT_CWD (set by npm during postinstall) differs from the project root. When the package is installed as a dependency, INIT_CWD points to the consumer's project directory, allowing the script to exit early. This prevents unnecessary Bun binary downloads for SDK consumers who only need the package as a library, not as a build tool.

The moved binaries are now treated as required dev dependencies rather than optional, ensuring consistent builds in development environments while the early-exit logic prevents them from being installed in dependent projects.

…ncies

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
Copy link
Member

@jonathanhefner jonathanhefner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude says:

npm's prepare lifecycle hook does exactly what you want:

  • Runs after npm install in the local project (development)
  • Does NOT run when the package is installed as a dependency from the npm registry
  • Also runs before npm pack / npm publish

This project already has it at package.json:65:

"prepare": "node scripts/setup-bun.mjs && npm run build && husky",

So the postinstall at line 47 is completely redundant. The simpler fix for the script side is to just delete the postinstall entry entirely and let prepare handle bun setup. No INIT_CWD detection needed.

...

The files field already excludes the script — Since "files": ["dist"], the scripts/setup-bun.mjs file isn't even shipped in the published package. The current postinstall already fails gracefully via || echo '...' for registry consumers. The real issue is just the optionalDependencies being downloaded, not the script executing.

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

3 participants