feat: support devEngines.packageManager for pnpm version management#10932
Merged
feat: support devEngines.packageManager for pnpm version management#10932
devEngines.packageManager for pnpm version management#10932Conversation
Support specifying the pnpm version via `devEngines.packageManager` in `package.json`. Unlike the `packageManager` field, this supports version ranges. The `onFail` field determines behavior on mismatch: - `download`: auto-download the matching pnpm version - `error`: fail with an error (default for single entry, last array element) - `warn`: warn but continue - `ignore`: skip check (default for non-last array elements) When both `packageManager` and `devEngines.packageManager` are present, `devEngines.packageManager` takes precedence and a warning is emitted. The resolved version is stored in `pnpm-lock.env.yaml` and reused if it still satisfies the range. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Mar 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for managing the pnpm CLI version via devEngines.packageManager (including semver ranges) and unifies package-manager enforcement/switching behavior through an onFail policy shared between pnpm and @pnpm/config.
Changes:
- Parse
devEngines.packageManager(incl. array form) and prefer it overpackageManager, emitting warnings and derivingonFailfor legacypackageManager. - Update CLI startup logic to use
onFailas the single source of truth for switching (download) vs. checking (error/warn/ignore), and allow semver ranges for pnpm version switching. - Expand test coverage for devEngines-based switching and checking; add
semverdependency to@pnpm/config.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm/test/switchingVersions.test.ts | Updates existing switching tests and adds devEngines-based version switching/range reuse scenarios. |
| pnpm/test/packageManagerCheck.test.ts | Adds devEngines onFail behavior tests and precedence over packageManager. |
| pnpm/src/switchCliVersion.ts | Resolves exact pnpm version from ranges via env lockfile and switches accordingly. |
| pnpm/src/main.ts | Routes switching/checking decisions through wantedPackageManager.onFail and uses semver range matching. |
| config/config/src/index.ts | Introduces getWantedPackageManager() + devEngines parsing; derives legacy packageManager onFail. |
| config/config/src/Config.ts | Replaces WantedPackageManager with EngineDependency for wantedPackageManager. |
| config/config/package.json | Adds semver + @types/semver deps for version/range validation. |
| pnpm-lock.yaml | Lockfile updates reflecting new semver dependencies. |
| .changeset/dev-engines-package-manager.md | Changeset documenting the new devEngines packageManager support. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add explicit type annotation for pmEngine variable - Close store controller on early return when version resolution fails - Expand version mismatch hint to mention devEngines.packageManager.onFail - Assert non-zero exit status in onFail=error test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`self-update` is an explicit user command, so it should always update the `packageManager` field when it points to pnpm, regardless of `managePackageManagerVersions` (which only controls automatic version switching). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a project uses devEngines.packageManager instead of packageManager, pnpm self-update now updates that field (both object and array forms) rather than incorrectly writing to packageManager. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ockfile writes - Add skipPackageManagerCheck = true so self-update is not blocked by BAD_PM_VERSION when the project specifies a different pnpm version - Only call resolvePackageManagerIntegrities for devEngines.packageManager (ranges need a lockfile); packageManager field doesn't need it Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
devEngines.packageManager for pnpm version management
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Add early return in parseDevEnginesPackageManager when array is empty to avoid accessing engines[0] / engines[-1] on an empty array - Fix misleading JSDoc in updateVersionConstraint: complex ranges that no longer satisfy the new version fall back to ^<newVersion>, not "left unchanged" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
devEngines.packageManagerinpackage.json, as an alternative to thepackageManagerfieldpackageManager,devEngines.packageManagersupports semver ranges — the resolved version is stored inpnpm-lock.env.yamland reused if it still satisfies the rangeonFailfield determines behavior:download(auto-download),error(default),warn, orignoredevEngines.packageManagertakes precedence overpackageManagerwhen both are present (with a warning)onFailisignorefor non-last elements anderrorfor the lastpackageManagerfield,onFailis derived from existing config settings (managePackageManagerVersions,packageManagerStrict,packageManagerStrictVersion), somain.tsusesonFailas the single source of truthEngineDependencytype from@pnpm/typesinstead of a customWantedPackageManagertypeTest plan
switchingVersions.test.ts— version switching withpackageManagerfield,devEngines.packageManagerwithonFail=download(exact + range), env lockfile reuse, corrupt binarypackageManagerCheck.test.ts— version checks withengines.pnpm,packageManagerfield,devEngines.packageManagerwith allonFailvalues, array notation, range matching, precedenceclose #8153