Skip to content

fix(deps): make @blockrun/clawrouter an optional peer dependency (3.6.0)#11

Merged
VickyXAI merged 2 commits into
mainfrom
fix/clawrouter-optional-peer
Jul 15, 2026
Merged

fix(deps): make @blockrun/clawrouter an optional peer dependency (3.6.0)#11
VickyXAI merged 2 commits into
mainfrom
fix/clawrouter-optional-peer

Conversation

@VickyXAI

Copy link
Copy Markdown
Contributor

Why

3.5.2 stopped loading the router unless smartChat() is called — but left it in optionalDependencies, which npm installs by default and npx consumers cannot opt out of (--omit=optional isn't reachable through npx).

So every install still paid the full cost:

size share of a @blockrun/mcp install
@blockrun/clawrouter ~50MB ~15% of 328MB
@blockrun/llm 712KB 0.2%

50MB 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 guarded await 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:

✓ NOT INSTALLED — clawrouter fully evicted
✓ module loads: LLMClient, BlockrunClient, createPaymentPayload, PaymentError all present
✓ smartChat() → "requires the optional '@blockrun/clawrouter' routing engine..." (graceful, actionable)

197 tests pass, typecheck ✓, build ✓.

Upgrading

  • Callers of chat(), wallet helpers, payment helpers: no action.
  • Callers of smartChat(): add @blockrun/clawrouter to your own dependencies. It is no longer installed for you.

Context

@blockrun/clawrouter@0.12.220 shipped a bundle that inlined a stale copy of itself, making every entrypoint a load-time SyntaxError. That took @blockrun/mcp down 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.

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.
@VickyXAI
VickyXAI merged commit 35c2bc2 into main Jul 15, 2026
3 checks passed
@VickyXAI
VickyXAI deleted the fix/clawrouter-optional-peer branch July 15, 2026 01:38
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.

1 participant