fix: make react a peer dependency to support multiple versions (#163) (#164)

Move react and react-dom from dependencies to peerDependencies with
support for React 17, 18, and 19. This allows consumers to use their
preferred React version instead of forcing v19.

- Added peerDependencies for react/react-dom (^17 || ^18 || ^19)
- Marked react dependencies as optional in peerDependenciesMeta
- Moved react/react-dom to devDependencies for local development
- React is already externalized in the build (build.bun.ts)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Olivier Chafik 2025-12-16 19:33:05 +00:00 • committed by GitHub
commit 31e05d31fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 6 deletions

16
package-lock.json generated
View file

@ -14,9 +14,7 @@
],
"dependencies": {
"@modelcontextprotocol/sdk": "^1.24.3",
"prettier": "^3.6.2",
"react": "^19.2.0",
"react-dom": "^19.2.0"
"prettier": "^3.6.2"
},
"devDependencies": {
"@playwright/test": "^1.52.0",
@ -30,6 +28,8 @@
"express": "^5.1.0",
"husky": "^9.1.7",
"nodemon": "^3.1.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"ts-to-zod": "^5.1.0",
"tsx": "^4.21.0",
"typedoc": "^0.28.14",
@ -55,7 +55,17 @@
"@rollup/rollup-win32-x64-msvc": "^4.53.3"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
"zod": "^3.25.0 || ^4.0.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
}
},
"examples/basic-host": {

View file

@ -59,6 +59,8 @@
"@types/bun": "^1.3.2",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"concurrently": "^9.2.1",
"cors": "^2.8.5",
"cross-env": "^10.1.0",
@ -73,13 +75,21 @@
"zod": "^4.1.13"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
"zod": "^3.25.0 || ^4.0.0"
},
"peerDependenciesMeta": {
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.24.3",
"prettier": "^3.6.2",
"react": "^19.2.0",
"react-dom": "^19.2.0"
"prettier": "^3.6.2"
},
"optionalDependencies": {
"@oven/bun-darwin-aarch64": "^1.3.4",