fix(deps): make @blockrun/clawrouter an optional peer dependency (3.6.0)#11
Merged
Conversation
3.5.2 stopped loading the router unless smartChat() was called, but left it in optionalDependencies — which npm installs by default and npx consumers cannot opt out of. Every install still paid ~50MB (about 15% of a @blockrun/mcp tree) for a routing engine most consumers never call. peerDependencies + peerDependenciesMeta.optional makes npm skip it entirely. No code change was needed: smartChat() already resolved the router through a guarded await import() and threw an actionable error when absent. The packaging just did not match that intent. Verified with the router absent: SDK imports cleanly, LLMClient/BlockrunClient/ createPaymentPayload/PaymentError all work, smartChat() fails with the 'requires the optional @blockrun/clawrouter routing engine' message. 197 tests, typecheck, build green.
CI runs pnpm install --frozen-lockfile and correctly rejected the drift after
clawrouter moved from optionalDependencies to an optional peerDependency.
pnpm's auto-install-peers still resolves it into this repo's own dev tree, which
is intended: smartChat() types reference typeof import("@blockrun/clawrouter"),
so typecheck needs it present locally. Consumers read the published package.json,
where peerDependenciesMeta.optional keeps npm from installing it — verified
against a packed tarball.
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.
Why
3.5.2 stopped loading the router unless
smartChat()is called — but left it inoptionalDependencies, which npm installs by default andnpxconsumers cannot opt out of (--omit=optionalisn't reachable throughnpx).So every install still paid the full cost:
@blockrun/mcpinstall@blockrun/clawrouter@blockrun/llm50MB of routing engine, downloaded by every consumer, to serve an opt-in code path most never call.
What
peerDependencies+peerDependenciesMeta.optional: true→ npm skips it entirely unless a consumer asks for it.No code change was needed.
smartChat()already resolved the router through a guardedawait import()and threw an actionable error when it was absent. The dependency was always designed optional; only the packaging disagreed.Verified
Fresh install of the packed 3.6.0 tarball:
197 tests pass, typecheck ✓, build ✓.Upgrading
chat(), wallet helpers, payment helpers: no action.smartChat(): add@blockrun/clawrouterto your own dependencies. It is no longer installed for you.Context
@blockrun/clawrouter@0.12.220shipped a bundle that inlined a stale copy of itself, making every entrypoint a load-timeSyntaxError. That took@blockrun/mcpdown for ~4 days (2026-07-11 → 07-14), reported by an external user. 3.5.2 already fixed the import-time blast radius; MCP never received it because it pinned^2.11.0. This change removes the dependency from the tree altogether, so the class of failure cannot reach consumers who don't route.