fix(react-doctor): resolve React from Bun grouped catalogs#192
fix(react-doctor): resolve React from Bun grouped catalogs#192invivek26 wants to merge 1 commit into
Conversation
Adds a branch in resolveCatalogVersion that walks workspaces.catalogs (Bun's named/grouped catalog map) in addition to workspaces.catalog. Previously, dependencies declared as 'react: catalog:<group>' against a Bun grouped catalog failed version resolution and threw the misleading 'No React dependency found' error. Closes millionco#191
|
@invivek26 is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
Merging this PR does not change React health
View top issues (1 of 1)
Analysis detailsanalyzed in 0.7s · nextjs · React 19.2.5 · TypeScript · 210 source files · powered by react-doctor |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f36880f. Configure here.
| if (version) return version; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Named catalog lookup is always skipped for root resolution
Medium Severity
The catalogName at line 279 is derived from the passed packageJson's own dependencies. In the primary call path (line 632), resolveCatalogVersion receives the root package.json, which typically has no react dependency — so catalogName is always null. This makes the specific named-catalog lookup at line 307 dead code. The fallback loop at lines 312–317 then scans all catalogs and returns the first match, which can resolve the wrong version when multiple named catalogs define the same package (e.g. react18 and react19 both declaring react).
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f36880f. Configure here.


Summary
Closes #191.
resolveCatalogVersionalready supports Bun's general catalog (workspaces.catalog) and pnpm catalogs, but ignores Bun's grouped/named catalogs atworkspaces.catalogs.<group>. Any dependency declared as"react": "catalog:<group>"therefore resolved tonulland the user got the misleadingNo React dependency founderror.This PR adds a parallel branch in
resolveCatalogVersionthat walksworkspaces.catalogs, mirroring the existing handling of the top-levelpackageJson.catalogskey:catalog:<name>reference first.Bun's grouped catalogs are documented at https://bun.com/docs/install/catalogs.
Repro (added as a test)
Root
package.json:{ "workspaces": { "packages": ["apps/*"], "catalogs": { "react19": { "react": "^19.1.4", "react-dom": "^19.1.4" } } } }App
package.json:{ "dependencies": { "react": "catalog:react19" } }discoverProject(...).reactVersion === null→ throwsNo React dependency found.discoverProject(...).reactVersion === "^19.1.4".Changes
src/utils/discover-project.ts— new branch inresolveCatalogVersionforworkspaces.catalogs.src/types.ts— extendPackageJson["workspaces"]withcatalogs?: Record<string, Record<string, string>>.tests/discover-project.test.ts— new test mirroring the existing Bun default-catalog test.tests/fixtures/bun-named-catalog-workspace/— minimal fixture..changeset/fix-bun-grouped-catalogs.md— patch changeset.Test plan
pnpm typecheckpnpm exec vp test run discover-project— 27 passed (was 26)src/utils/discover-project.ts+src/types.ts, the new test fails (reactVersionisnull); reapplied, passes.pnpm formatpnpm lint— 0 warnings, 0 errorspnpm testwas not run cleanly; on a fresh checkout the regression suite fails for an unrelated reason (Cannot find module .../utils/react-doctor-plugin.js— the oxlint JS plugin appears to need a build step before tests). Happy to chase down the right pre-test command if you can point me at it.Note
Low Risk
Low risk: small, additive change to dependency version resolution logic with a focused test/fixture; main risk is unintended precedence when multiple catalogs define the same package.
Overview
Fixes React version detection for Bun workspaces that use grouped/named catalogs under
workspaces.catalogs.<name>when dependencies are declared as"react": "catalog:<name>".resolveCatalogVersionnow checksworkspaces.catalogsby first trying the referenced named catalog and then falling back to scanning all catalogs, andPackageJsontyping plus tests/fixtures and a patch changeset are updated accordingly.Reviewed by Cursor Bugbot for commit f36880f. Bugbot is set up for automated code reviews on this repo. Configure here.