Skip to content

feat(tools): add Rush monorepo support#176

Open
clanzhang wants to merge 1 commit into
antfu:mainfrom
clanzhang:feat/rush-monorepo-support
Open

feat(tools): add Rush monorepo support#176
clanzhang wants to merge 1 commit into
antfu:mainfrom
clanzhang:feat/rush-monorepo-support

Conversation

@clanzhang

Copy link
Copy Markdown

Description

Closes #139

Add support for Rush monorepos by detecting
rush.json and using rush-pnpm as the executable in the pnpm agent.

How it works

Rush provides rush-pnpm — a transparent wrapper around the user's
pnpm binary that configures it to work within the Rush monorepo.
Since rush-pnpm accepts the same CLI arguments as pnpm, we only
need to swap the executable.

Detection strategy:

  1. Before falling back to package-manager-detector, check for
    rush.json by traversing up from cwd.
  2. If found, set options.rush = true and return 'pnpm' as the agent.
  3. The pnpm agent reads options.rush and uses rush-pnpm instead of pnpm.

Changes

  • types/base.ts — Add optional rush?: boolean to BaseOptions
  • utils/rush.ts — New module: isRushMonorepo() and findRushRoot()
  • agent-entry/detect.ts — Pre-check for Rush before package-manager-detector
  • agents/pnpm/list.ts — Resolve executable dynamically via resolveExecutable()

Notes

  • rush-pnpm is CLI-compatible with pnpm, so pnpm ls, pnpm root, etc.
    work identically. No argument construction logic changes.
  • getCatalogs() returns {} automatically for Rush projects since they
    don't have pnpm-workspace.yaml.
  • No new dependency is introduced.

Validations

Add Rush monorepo detection and route pnpm agent to use
when running inside a Rush workspace. Rush provides  as a
CLI-compatible wrapper around pnpm, so only the executable name needs
to change — no argument construction logic is affected.

- Add  to BaseOptions
- Add  with isRushMonorepo() and findRushRoot()
- Pre-check for rush.json in getPackageManager() before package-manager-detector
- Resolve pnpm executable dynamically in pnpm agent based on options.rush

Closes antfu#139
@antfu

antfu commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Would you like to contribute to package-manager-detector first to make this more generic? Thanks

@clanzhang

Copy link
Copy Markdown
Author

Would you like to contribute to package-manager-detector first to make this more generic? Thanks

Sure! I'll contribute to package-manager-detector first to add Rush support there.

One question before I start: currently detect() returns the package manager name as a string. For Rush, we need to signal both "this is pnpm" and "use rush-pnpm as the executable". Would you prefer:

A separate export like getAgent() that returns both the package manager and the resolved executable name?
Or extend the return type to include an optional executable field?
Happy to go with whichever approach you think fits best.

@antfu

antfu commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Maybe we could have pnpm-rush type, that inherits things from pnpm. And after package-manager-detector gets released, in node-modules-inspector we would accept both pnpm and pnpm-rush as supported agents.

@clanzhang

Copy link
Copy Markdown
Author

Maybe we could have pnpm-rush type, that inherits things from pnpm. And after package-manager-detector gets released, in node-modules-inspector we would accept both pnpm and pnpm-rush as supported agents.

Hi @antfu, I've opened a PR on package-manager-detector as you suggested:

antfu-collective/package-manager-detector#75

Added pnpm-rush as a new agent type inheriting from pnpm, with rush-pnpm as the executable. Rush detection is done via rush.json in the directory traversal, following the same pattern as yarn/yarn@berry.

Once it's released, I'll update the node-modules-inspector PR to consume the new version. Let me know if anything needs to be adjusted.

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.

feat: add support for rush monorepos

2 participants