fix: bundle SDK+zod in react-with-deps (was byte-identical to ./react)#539
Open
fix: bundle SDK+zod in react-with-deps (was byte-identical to ./react)#539
Conversation
The react-with-deps build entry was introduced in PR #221 (e078250) as a sibling to app-with-deps for CDN/unpkg no-bundler use. But its external array was duplicated without editing — it never dropped @modelcontextprotocol/sdk from externals, so it has shipped byte-identical to ./react for 10 releases (v0.3.1 → v1.2.0). After #534 merged, both entries use ['react', 'react-dom', ...PEER_EXTERNALS] — still identical, just smaller. Delete rather than fix: React apps always use a bundler; the CDN/unpkg use case (HTML-string apps like qr-server) doesn't apply to React hooks. Zero consumers verified (examples/docs/tests/plugins).
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-preact
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-solid
@modelcontextprotocol/server-basic-svelte
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-basic-vue
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-debug
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
Reverts the deletion from the previous commit and applies the actual fix. The react-with-deps external array was copy-pasted in PR #221 without dropping PEER_EXTERNALS — now it mirrors app-with-deps: bundles @modelcontextprotocol/sdk + zod for CDN/import-map consumers. React and react-dom MUST remain external — bundling them would cause dual-React-instance hooks errors. Consumer provides them via import map. Before: index.js 26KB == react-with-deps.js 26KB (identical MD5) After: index.js 26KB != react-with-deps.js 323KB (SDK+zod bundled)
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.
Problem
Copy-paste bug from PR #221 (commit
e078250a, 2026-01-09). That PR addedapp-with-depsandreact-with-depsas siblings for CDN/import-map no-bundler consumption. But thereact-with-depsexternalarray was duplicated from the regular./reactentry without dropping@modelcontextprotocol/sdk— so it never actually bundled anything extra.Result:
react-with-deps.jshas shipped byte-identical toreact/index.jsfor 10 releases (v0.3.1 → v1.2.0). Same MD5, same bytes. After #534 (zod externalized viaPEER_EXTERNALS), both entries used["react", "react-dom", ...PEER_EXTERNALS]— still identical.Fix
Drop
...PEER_EXTERNALSfrom thereact-with-depsexternalarray so it mirrorsapp-with-deps: bundle@modelcontextprotocol/sdk+zod, keep only React external.buildJs("src/react/index.tsx", { outdir: "dist/src/react", - external: ["react", "react-dom", ...PEER_EXTERNALS], + external: ["react", "react-dom"], naming: { entry: "react-with-deps.js" }, }),React and react-dom MUST stay external — bundling them would cause dual-React-instance hooks errors (
Invalid hook call). The consumer provides React via an import map (esm.sh, unpkg, etc.).Use case
ESM-from-CDN React apps using import maps — no npm, no bundler:
Verification
index.js(./react)react-with-deps.js852ae4b6...fb54392b...from"@modelcontextprotocol/sdk"from"zod"from"react"Module smoke test:
node -e "import(...)"→ parses cleanly, exportsuseApp,useAutoResize,useDocumentTheme,useHostStyles,App,PostMessageTransport, all Zod schemas.Net diff vs
mainOne line in
build.bun.ts.package.jsonunchanged.