Skip to content

fix(hub-ui): make json-render an optional peer - #235

Merged
antfu merged 1 commit into
mainfrom
plan-036-hub-ui-optional-peer
Aug 15, 2026
Merged

fix(hub-ui): make json-render an optional peer#235
antfu merged 1 commit into
mainfrom
plan-036-hub-ui-optional-peer

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Intent

hub-ui's only source-level use of @devframes/json-render is a single side-effect import for declaration merging (src/client/types.ts), registering the 'json-render' dock entry type on the hub's open dock union. All other mentions in src/ are comments/strings. But package.json declared it a non-optional peer, so npm≥7 auto-installs it — dragging the zod closure (~6 MB: zod 4.6 MB + @json-render/core 0.9 MB + @json-render/vue) into every hub-ui install, even hosts that never render a json-render dock.

Changes

  • packages/hub-ui/package.json: @devframes/json-render stays in peerDependencies (so the workspace build graph still typechecks and consumers still get the type) but is now marked optional: true via peerDependenciesMeta, mirroring the shape packages/json-render/package.json already uses for its own optional @devframes/hub peer.
  • packages/hub-ui/src/client/types.ts: kept the plain (non-import type) side-effect import — TS rejects a type-only side-effect import since there are no bindings to mark as type-only — and added a comment explaining why, and that it's fully erased at build time regardless.

Verification

  • dist/index.mjs, dist/index.d.mts, dist/client/embedded.js, and dist/client/standalone/** have zero json-render references, both before and after this change — the declaration merge never leaked into the published build, so demoting the peer is consumer-invisible.
  • Every example that renders a json-render dock (hub-vite-minimal, hub-next-minimal, hub-rsbuild-minimal, hub-vite, hub-next) already declares @devframes/json-render and @devframes/json-render-ui explicitly in its own package.json — none relied on the transitive peer, so no example changes were needed.
  • docs/guide/hub-initiate.md's renderer-modules section already cross-links to docs/guide/json-render.md, which spells out the two-package install — no doc gaps to close.
  • Full pre-PR suite: pnpm lint && pnpm knip && pnpm test && pnpm typecheck && pnpm build — all green except one pre-existing, unrelated tsnapi snapshot flake in @devframes/plugin-assets (a nondeterministic union-member ordering in generated .d.ts, reproduced identically on the unmodified base commit via git stash).

Created with the help of an agent.

hub-ui's only source-level use of @devframes/json-render is a side-effect
import for declaration merging (registering the 'json-render' dock entry
type). Dist (runtime and .d.mts) never references json-render, so keeping
it a required peer just forces every hub-ui install to auto-install the
zod closure it pulls in, even for hosts that never render a json-render
dock.

Mirror the optional-peer shape @devframes/json-render already uses for
its own optional @devframes/hub peer: keep @devframes/json-render in
peerDependencies (for the workspace build graph and consumer typing) but
mark it optional via peerDependenciesMeta. Hosts that render json-render
docks now install @devframes/json-render(-ui) explicitly, which every
existing example already does.
@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit d94dc12
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a8011bd3a764a00081d0a88
😎 Deploy Preview https://deploy-preview-235--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 3afb315 into main Aug 15, 2026
12 checks passed
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.

2 participants