Skip to content

React version detection fails for Bun grouped catalogs (workspaces.catalogs.<group>) #191

Description

@invivek26

Follow-up to #87. v0.1.4 resolves Bun's general catalog (workspaces.catalog), but grouped catalogs (workspaces.catalogs.<group>) are still not resolved.

Environment

  • react-doctor: 0.1.4
  • Package manager: Bun 1.3.1
  • Monorepo with Bun workspace grouped catalogs

Reproduction

  1. Root package.json:
    {
      "workspaces": {
        "packages": ["apps/*"],
        "catalogs": {
          "react19": {
            "react": "19.2.0",
            "react-dom": "19.2.0"
          }
        }
      }
    }
  2. App package.json (e.g. apps/web/package.json):
    {
      "dependencies": {
        "react": "catalog:react19",
        "react-dom": "catalog:react19"
      }
    }
  3. From the repo root:
    bunx react-doctor@latest

Actual behavior

Scanning /repo/apps/web...
Something went wrong. Please check the error below for more details.

No React dependency found in /repo/apps/web/package.json.
Add "react" to dependencies (or peerDependencies) and re-run.

Expected behavior

react-doctor should resolve catalog:<group> references against the root workspaces.catalogs.<group> map and report the concrete React version (19.2.0 here).

Root cause

In dist/index.js (resolveCatalogVersion, ~lines 773–800), only these locations are checked:

  • packageJson.catalog (top-level)
  • packageJson.catalogs (top-level)
  • packageJson.workspaces.catalog (Bun general catalog) ✅
  • pnpm-workspace.yaml

The Bun grouped location — packageJson.workspaces.catalogs[catalogName] — is never read, so any dep declared as catalog:<group> resolves to null and downstream throws the misleading "No React dependency found" error.

Suggested fix

After the existing workspaces.catalog branch, add a parallel branch for workspaces.catalogs mirroring the top-level packageJson.catalogs handling:

if (workspaces && !Array.isArray(workspaces) && isPlainObject(workspaces.catalogs)) {
  const namedCatalog = catalogName ? workspaces.catalogs[catalogName] : undefined;
  if (namedCatalog && isPlainObject(namedCatalog)) {
    const version = resolveVersionFromCatalog(namedCatalog, packageName);
    if (version) return version;
  }
  for (const catalogEntries of Object.values(workspaces.catalogs)) {
    if (isPlainObject(catalogEntries)) {
      const version = resolveVersionFromCatalog(catalogEntries, packageName);
      if (version) return version;
    }
  }
}

Reference: https://bun.com/docs/install/catalogs (grouped catalogs are documented under workspaces.catalogs).

Happy to send a PR if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions