Skip to content

[rush] Close native pnpm compatibility gaps - #6131

Merged
Bharat Middha (bmiddha) merged 6 commits into
mainfrom
bmiddha/pnpm12-native-compat
Oct 14, 2026
Merged

Bharat Middha (bmiddha) merged 6 commits into
mainfrom
bmiddha/pnpm12-native-compat

Conversation

@bmiddha

Copy link
Copy Markdown
Member

Summary

Close five independently scoped compatibility gaps for native pnpm, preserving
the existing behavior for earlier pnpm versions:

  • Normalize v9 importer references when a workspace-only lockfile omits snapshots.
  • Use the native configuration prefix for store, cache and state directories.
  • Do not let npmrc settings that native pnpm ignores suppress Rush defaults.
  • Reject the removed resolution-only operation before installation side effects.
  • Pass the compatibility-database boolean explicitly to native pnpm, retaining
    the legacy argument form for pnpm 8, 10 and 11.

Each fix has its own commit, focused regressions and a change entry. The
store-environment tests use the current controlled-constructor test pattern
rather than accessing ECMAScript private members.

Validation

  • Current-main dependency closure: 35 successful build operations.
  • Rush library TypeScript, ESLint, API Extractor and Webpack build passed.
  • 139 tests passed in eight focused suites, including all new regressions.
  • The publication branch has the exact tested file tree; only Git author
    metadata was normalized to the repository's required noreply identity.

Scope and dependencies

This SUPPORT PR does not select pnpm 12 for this repository or change dependency
versions, build approvals, trust policy or release-age policy.

Existing #6119 addresses copying back a changed temporary lockfile after
rush update. It remains a separate dependency for complete native update
support and is deliberately not duplicated in this diff.

Injected-dependency synchronization and opt-in lock-retaining autoinstaller
reconciliation are separate SUPPORT changes. Repository adoption is a separate
USE change, with its own frozen-install, integrity, peer-graph and build gates.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The install-critical changes hinge on external native-pnpm-12 behavior (env-var prefixes and CLI/flag parsing) that cannot be verified here, warranting human validation.

0 open findings

What changed in this PR

This PR closes five independently scoped compatibility gaps for native pnpm (v11/v12) while preserving behavior for earlier pnpm versions. It fits into @microsoft/rush's install pipeline, which must branch on the pnpm major version because native pnpm changes config/CLI/env semantics (e.g., pnpm 12 ignores NPM_CONFIG_* env vars and no longer reads several settings from .npmrc). Each fix is paired with focused regression tests and a change entry.

Changes:

  • Normalize v9 lockfile importers even when a workspace-only/empty graph omits the snapshots section (PnpmShrinkwrapFile.ts now converts for any lockfile major version ≥ 9 instead of gating on snapshots).
  • Preserve Rush auto-install-peers/resolution-mode defaults (and warn) when pnpm 11+ ignores obsolete .npmrc settings, and pass an explicit =true for ignoreCompatibilityDb to native pnpm 12.
  • Use the native PNPM_CONFIG_ prefix for store/cache/state dirs in rush-pnpm, and reject --resolution-only before any install side effects on pnpm 12+.
File Description
libraries/​rush-lib/​src/​logic/​pnpm/​PnpmShrinkwrapFile.ts Convert v9+ lockfiles even without a snapshots section so workspace-only importers normalize correctly.
libraries/​rush-lib/​src/​logic/​base/​BaseInstallManager.ts Gate .npmrc-derived peer/resolution settings on pnpm < 11, warn when ignored, and pass explicit ignoreCompatibilityDb=true for pnpm 12+.
libraries/​rush-lib/​src/​cli/​RushPnpmCommandLineParser.ts Choose PNPM_CONFIG_/NPM_CONFIG_ env prefix for store/cache/state by pnpm major; add _executeForTestingAsync hook.
libraries/​rush-lib/​src/​cli/​actions/​InstallAction.ts Reject --resolution-only for pnpm 12+ before project selection; update parameter description and fix a typo.
libraries/​rush-lib/​src/​logic/​pnpm/​PnpmOptionsConfiguration.ts Update doc comments to reflect pnpm 11+ ignoring .npmrc for these settings.
libraries/​rush-lib/​src/​logic/​pnpm/​test/​PnpmShrinkwrapFile.test.ts New tests for snapshot-less v9 importer normalization.
libraries/​rush-lib/​src/​logic/​test/​BaseInstallManager.test.ts New tests for config-arg generation across pnpm versions/npmrc states.
libraries/​rush-lib/​src/​cli/​test/​RushPnpmCommandLineParser.test.ts New tests for env prefix/override precedence per pnpm version.
libraries/​rush-lib/​src/​cli/​test/​InstallAction.test.ts New tests for the --resolution-only rejection path.
common/​changes/​@microsoft/​rush/​*.json (5) Change entries for the five fixes.

No blocking in-diff issues were found: the enum/import for ShrinkwrapFileMajorVersion.V9 exist, convertLockfileV9ToLockfileObject safely handles missing snapshots (snapshots ?? {}), semver is imported where used, test fixtures resolve, and the pnpm-version branching is consistent with existing codebase patterns. One note for human attention: correctness depends on external pnpm 12 runtime semantics (env-var prefix, ignoreCompatibilityDb flag parsing) that cannot be fully verified in this environment, and the adjacent unchanged NPM_CONFIG_WORKSPACE_DIR (line 531) is left with the legacy prefix.

🧠 Review effort: Max


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Keep importer normalization active when a native workspace-only lockfile omits snapshots. Preserve earlier lockfile paths and the focused regressions.

Original-Support-Commit: 8d508eec12c33c38a5573594148e9106c6c07e62
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bedb50cb-fcd4-4dc4-83b9-dba6064e5498
Use native pnpm's prefix for store, cache and state while retaining older-manager precedence. Exercise the current branded parser through the existing controlled-test pattern instead of accessing removed TypeScript private fields.

Original-Support-Commit: 840e38962d236834bb2cf962ca584a6aab2953cd
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bedb50cb-fcd4-4dc4-83b9-dba6064e5498
Original-Support-Commit: b76cc141b6be5652c3d55c8721aec0a4ba01fdcb
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bedb50cb-fcd4-4dc4-83b9-dba6064e5498
Original-Support-Commit: 33003805b0d30348beef651ce019b70d11a48221
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bedb50cb-fcd4-4dc4-83b9-dba6064e5498
Preserve the existing compatibility database policy with an explicit native boolean, without changing legacy pnpm arguments.

Original-Support-Commit: acfc4d4a9956e1f3635b000b66c3f54c204a33e8
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bedb50cb-fcd4-4dc4-83b9-dba6064e5498
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The compatibility changes are narrowly scoped, internally consistent, and covered by focused regressions.

0 open findings

🧠 Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants