Skip to content

vp migrate keeps writing a vitest entry into pnpm peerDependencyRules, which hides real peer mismatches, and writes it back after it is removed #3604

In review

Description

@caglarenes

Describe the bug

In a pnpm workspace that uses Vitest directly (here, through @vitest/coverage-v8), vp migrate writes:

peerDependencyRules:
  allowAny:
    - vitest
  allowedVersions:
    vitest: "*"

The catalog it writes pins vitest to a real Vitest version (vitest: 5.1.1, the one Vite+ bundles), not an alias. Peer ranges on vitest are therefore checked against a real version and are met as they are: in the reproduction, pnpm peers check finds nothing with the rule or without it. All the rule can still do is silence a real mismatch, such as a plugin whose vitest peer range excludes the bundled version.

That is the reasoning pnpmPeerDependencyRuleKeys (packages/cli/src/migration/migrator/vitest-ecosystem.ts) already applies to vite. The vite rule is dropped once the core's version encodes the Vite it bundles, because "then it only hides real incompatibilities". vitest gets no such condition: it is managed whenever the workspace uses Vitest.

Two more things make it stick:

  • A workspace that removes the rule is reported as needing an update. The next vp migrate prints "Package manager settings configured" and writes the rule back.
  • pnpm's documentation marks peerDependencyRules as deprecated, starting with the 12.17 docs, and points to overrides with :peer for changing peer ranges. pnpm still applies the field and does not warn, so this is not breaking anything today.

Would you consider writing the vitest rule only when it is needed (as for vite), and leaving a workspace without it alone?

Reproduction

Steps below (no repository needed).

Steps to reproduce

set -eu
root=$(mktemp -d)
cd "$root"
cat >package.json <<'EOF'
{
  "name": "app",
  "private": true,
  "type": "module",
  "packageManager": "pnpm@12.23.0",
  "scripts": { "test": "vitest run" },
  "devDependencies": {
    "@vitest/coverage-v8": "5.1.1",
    "vite": "8.3.8",
    "vitest": "5.1.1"
  }
}
EOF
echo 'packages: []' >pnpm-workspace.yaml
echo 'export default {};' >vite.config.ts
mkdir src
printf "import { expect, test } from 'vitest';\ntest('one', () => expect(1).toBe(1));\n" >src/one.test.ts
echo node_modules >.gitignore
git init -q && pnpm install >/dev/null && git add -A && git commit -qm init

vp migrate --no-interactive --no-agent --no-editor --no-hooks
grep -A4 '^peerDependencyRules' pnpm-workspace.yaml
pnpm peers check

# Remove the rule and install again.
node -e 'const fs = require("fs"); fs.writeFileSync("pnpm-workspace.yaml", fs.readFileSync("pnpm-workspace.yaml", "utf8").replace(/^peerDependencyRules:\n(?:[ \t].*\n?)*/m, ""))'
pnpm install >/dev/null
pnpm peers check
git add -A && git commit -qm "no vitest peer rule"

vp migrate --no-interactive --no-agent --no-editor --no-hooks
grep -A4 '^peerDependencyRules' pnpm-workspace.yaml

System Info

# The global CLI is not installed here, so there is no `vp env current`.
$ vp --version
vp v1.8.0

Local vite-plus:
  vite-plus  v1.8.0

Node 26.13.1, pnpm 12.23.0, Windows 11

Used Package Manager

pnpm

Logs

The steps above, run as written:

$ vp migrate --no-interactive --no-agent --no-editor --no-hooks
◇ Migrated . to Vite+ 1.8.0
• Node 26.13.1  pnpm 12.23.0
✓ Dependencies installed in 4.2s
• 1 file had imports rewritten
$ grep -A4 '^peerDependencyRules' pnpm-workspace.yaml
peerDependencyRules:
  allowAny:
    - vitest
  allowedVersions:
    vitest: "*"
$ pnpm peers check
No peer dependency issues found

# after removing the rule and installing again
$ pnpm peers check
No peer dependency issues found

$ vp migrate --no-interactive --no-agent --no-editor --no-hooks
◇ Updated . to Vite+ 1.8.0
• Node 26.13.1  pnpm 12.23.0
✓ Dependencies installed in 329ms
• Package manager settings configured
$ grep -A4 '^peerDependencyRules' pnpm-workspace.yaml
peerDependencyRules:
  allowAny:
    - vitest
  allowedVersions:
    vitest: "*"

AI disclosure: I found and wrote this with Claude Code (model: Claude Opus 5.5, claude-opus-5-5; its reasoning effort level is not shown to me). I ran the steps above with vite-plus 1.8.0 and pnpm 12.23.0.

Activity

  1. added theissue type on Nov 29, 2026
  2. voidzero-bot commented on Nov 29, 2026

    @voidzero-bot
    Contributor
    • Reproduced: Yes
    • Exploration: Yes — View branch
    • Unit Test: Yes — packages/cli/src/migration/__tests__/vite-peer-dependency-rule.spec.ts
    • Priority: Priority P3: minor bug. This affects only pnpm workspaces that use Vitest directly, and it causes no install or build failures — the managed rule merely silences genuine vitest peer-mismatch reports and re-inserts itself after removal. It contradicts the project's own documented "rule only when needed" policy (and the core-version-alignment RFC explicitly deferred this removal to a follow-up), but the user-visible impact stays limited to masked peer warnings in a specific package-manager setup.

    Both reported symptoms reproduce on current main: vp migrate writes peerDependencyRules: { allowAny: [vitest], allowedVersions: { vitest: "*" } } for every Vitest-using pnpm workspace, and a workspace that removes the rule is flagged as pending ("Package manager settings configured") so the next migration writes it back. The root cause is pnpmPeerDependencyRuleKeys (packages/cli/src/migration/migrator/vitest-ecosystem.ts), which keeps vitest in the managed peer-rule keys whenever the workspace uses Vitest — with no "only when needed" condition like the one vitePeerDependencyRuleRequired applies to vite. The rule's original purpose vanished in #1588, when the @voidzero-dev/vite-plus-test wrapper was deleted and the managed vitest became the real bundled version; since then pnpm checks vitest peer ranges against a genuine version, so the rule can only hide real incompatibilities (verified empirically: @vitest/coverage-v8@2.0.5 against bundled vitest 5.1.1 is reported by pnpm peers check without the rule and silently accepted with it).

    I found a potential fix for this issue. It mirrors the vite handling for vitest: a new vitestPeerDependencyRuleRequired drops the rule from the managed peer-rule keys unless the managed spec still needs it (wrapper alias, dist-tag, file:/URL spec, or prerelease/build), a lingering managed rule is treated as stale and removed, a user-authored allowedVersions.vitest range other than '*' is preserved, and the migrate summary names the removed rule. The suggested changes are on the branch above — they pass the migration unit suite (12 new regression assertions fail without the fix), 350 migration snapshot trials, and an end-to-end run of your reproduction — but they need human review before merging.

    Full Triage Report

    Triage Report — Issue #3604 (reproduce stage)

    Issue summary

    vp migrate writes a vitest entry into pnpm peerDependencyRules
    (allowAny: [vitest], allowedVersions: { vitest: "*" }) in workspaces that use
    Vitest directly (here through @vitest/coverage-v8). The catalog that migration
    writes pins vitest to a real bundled Vitest version (vitest: 5.1.1), not an
    alias, so vitest peer ranges are satisfied without any rule — pnpm peers check
    finds no issues with or without it. The rule can therefore only silence a real
    peer mismatch (e.g. a plugin whose vitest peer range excludes the bundled
    version). Additionally, a workspace that removes the rule is treated as needing
    an update: the next vp migrate prints "Package manager settings configured"
    and writes the rule back. The vite rule gets no equivalent treatment only via
    vitePeerDependencyRuleRequired — vitest has no such "only when needed"
    condition in pnpmPeerDependencyRuleKeys
    (packages/cli/src/migration/migrator/vitest-ecosystem.ts).

    Expected: the vitest peer rule is written only when needed (as for vite),
    and a workspace without it is left alone.
    Actual: the rule is always written for Vitest-using workspaces, and is
    re-inserted after the user removes it.

    Environment

    • Vite+ checkout at 5cf0b72c8 ("fix(cli): run a selected app target with its
      own toolchain (fix(cli): run a selected app target with its own toolchain #3509)"), branch triagebot/fix-3604; vp v1.8.0 installed
      from this checkout on PATH.
    • Host: Linux x64, Node.js v24.22.3, pnpm v12.11.2 (the reproduction pins
      packageManager: pnpm@12.23.0, which the migration honored).
    • vp migrate was run through the local registry wrapper:
      node packages/tools/src/local-npm-registry.ts --pack -- vp migrate ….

    Reproduction path

    /tmp/vite-plus-triage/gh-3604/repro (steps as in the issue) and
    /tmp/vite-plus-triage/gh-3604/control (control case).

    Commands attempted and results

    1. Setup (exactly as in the issue)

    Created package.json with devDependencies @vitest/coverage-v8@5.1.1,
    vite@8.3.8, vitest@5.1.1, pnpm-workspace.yaml with packages: [],
    vite.config.ts, src/one.test.ts; pnpm install and an initial git commit.

    2. First vp migrate (wrapped in the local registry)

    $ node .../local-npm-registry.ts --pack -- vp migrate --no-interactive --no-agent --no-editor --no-hooks
    ◇ Migrated . to Vite+ 1.8.0
    • Node 26.13.1  pnpm 12.23.0
    ✓ Dependencies installed in 804ms
    • 1 file had imports rewritten
    

    pnpm-workspace.yaml afterwards ends with:

    peerDependencyRules:
      allowAny:
        - vitest
      allowedVersions:
        vitest: "*"

    Note: no vite rule was written — vitePeerDependencyRuleRequired deems the
    core alias sufficient on this pnpm version, while vitest gets no such
    condition. Reproduced (part 1).

    3. pnpm peers check — with the rule and without it

    Both runs: No peer dependency issues found. The rule is not needed in this
    workspace.

    4. Remove the rule, reinstall, commit

    Stripped the peerDependencyRules block, pnpm install, pnpm peers check
    (still no issues), committed.

    5. Second vp migrate

    ◇ Updated . to Vite+ 1.8.0
    • Node 26.13.1  pnpm 12.23.0
    ✓ Dependencies installed in 23ms
    • Package manager settings configured
    

    pnpm-workspace.yaml again contains:

    peerDependencyRules:
      allowAny:
        - vitest
      allowedVersions:
        vitest: "*"

    Reproduced (part 2): the removed rule is reported as a pending setting and
    written back.

    6. Control — non-Vitest workspace

    /tmp/vite-plus-triage/gh-3604/control: plain vite@8.3.8 project, same
    migrate command. Resulting pnpm-workspace.yaml:

    packages: []
    catalog:
      vite: npm:@voidzero-dev/vite-plus-core@8.3.8001
      vite-plus: 1.8.0
    overrides:
      vite@*: "catalog:"

    No peerDependencyRules at all — the vitest rule is specific to workspaces
    that use Vitest directly, not written unconditionally. Control passes; the
    failure is not an unrelated "always writes peer rules" bug.

    Result

    Reproduced on current main (v1.8.0 checkout), with the local build, both
    halves of the report: (1) the vitest peer rule is written for a Vitest-using
    workspace even though pnpm peers check needs no rule, and (2) removing the
    rule makes the next vp migrate rewrite it ("Package manager settings
    configured").

    Observations for diagnosis (no fix proposed)

    • pnpmPeerDependencyRuleKeys in
      packages/cli/src/migration/migrator/vitest-ecosystem.ts builds managed
      from managedOverridePackages(usesVitest) keys, filtering out vite when
      vitePeerDependencyRuleRequired is false. vitest is kept whenever
      usesVitest is true — there is no "rule only when the catalog entry is not a
      real version satisfying peers" condition like the one vite has.
    • The stale list only removes vitest when the workspace does NOT use
      Vitest, so a user-removed rule in a Vitest-using workspace is indistinguishable
      from a migration-written one and is restored by
      mergeManagedPnpmPeerDependencyRules.
    • The written catalog pins vitest: 5.1.1 (a real version, bundled with
      vite-plus), so peer ranges on vitest are checked against and satisfied by a
      concrete version; the allowedVersions: { vitest: "*" } / allowAny entry
      can only suppress genuine mismatches.
    • pnpm's docs mark peerDependencyRules deprecated (from the 12.17 docs) in
      favor of :peer overrides; pnpm 12.23 still applies the field silently.

    Diagnosis — Issue #3604 (diagnose stage)

    Root cause

    The vitest pnpm peerDependencyRules entry is written (and re-written) because
    pnpmPeerDependencyRuleKeys puts vitest into managed unconditionally
    whenever the workspace uses Vitest
    , with no "rule only when needed" condition.
    The analogous condition exists only for vite
    (vitePeerDependencyRuleRequired).

    Affected code (all in packages/cli/src/migration/migrator/):

    • vitest-ecosystem.ts:606-626 — pnpmPeerDependencyRuleKeys (the core of
      the bug). managed is derived from the keys of
      managedOverridePackages(usesVitest) (line 343), which contains vitest
      whenever usesVitest is true. The only filter is
      (key) => viteRuleRequired || key !== 'vite' — vitest never gets a
      vitestPeerDependencyRuleRequired-style check. stale contains vitest
      only when !usesVitest, so in a Vitest-using workspace a user-removed rule
      is indistinguishable from a migration-written one and is treated as missing.
    • shared.ts:266-284 — vitePeerDependencyRuleRequired: the model for the
      missing condition. It returns false when the core alias version encodes the
      bundled Vite (stable major ≥ 8) on pnpm ≥ 10.2.0, with the explicit comment
      that then "the rule would only hide real incompatibilities".
    • vitest-ecosystem.ts:654-685 — mergeManagedPnpmPeerDependencyRules and
      catalog.ts:462-497 (pnpm-workspace.yaml writer): both add every
      managed key to allowAny and set allowedVersions[key] = '*', so vitest
      is (re)written.
    • vite-plus-bootstrap.ts:209-222 — pnpmPeerDependencyRulesSatisfyVitePlus
      and its call sites (vite-plus-bootstrap.ts:793/808/824/1132/1234,
      orchestrators.ts:235, catalog.ts:1301): pending-detection requires
      managed.every(key => allowAny.has(key) && allowedVersions[key] === '*').
      A workspace that removed the vitest rule is therefore flagged pending, the
      reconcile path runs (vite-plus-bootstrap.ts:1294 sets
      report.packageManagerBootstrapConfigured), bin.ts:662-664 prints
      "Package manager settings configured", and the rule is written back. This is
      symptom 2.
    • vitest-ecosystem.ts:629-632 — isManagedAllowedVersion exempts only
      vite from the '*' check; a hypothetical user-authored non-*
      allowedVersions.vitest range is currently overwritten.

    Why the rule was ever needed (history)

    • PR fix(cli): add peerDependencyRules for standalone pnpm projects #1222 (487e33891) added the pnpm peerDependencyRules "because packages
      expecting vite saw the vite-plus version instead" — at that time vitest
      was aliased to the wrapper npm:@voidzero-dev/vite-plus-test@latest, whose
      version did not encode a real Vitest version, so vitest peer ranges were
      checked against a non-vitest version and the rule silenced the noise.
    • PR refactor: replace @voidzero-dev/vite-plus-test with upstream vitest #1588 (342fd2f44, June 2026) deleted the wrapper and changed the managed
      vitest override to the real bundled version
      (VITE_PLUS_OVERRIDE_PACKAGES.vitest = VITEST_VERSION, utils/constants.ts:64,
      currently 5.1.1). From that point, vitest peer ranges are checked against
      a genuine Vitest version and are satisfied without any rule — the rule's
      original purpose disappeared, but nothing removed it from managed.
    • PR feat: align the core version with the bundled Vite version #3317 (4dc066a44, Nov 2026) then introduced the "drop when not needed"
      behavior, but scoped it to vite only (core-version alignment RFC). The
      vitest key stayed in managed whenever usesVitest.

    Why it only hides real mismatches (verified empirically)

    The catalog pin (vitest: 5.1.1) is a real Vitest version, so pnpm checks
    vitest peer ranges against it legitimately. Scratch proof in
    /tmp/vite-plus-triage/gh-3604/peer-proof (vitest 5.1.1 +
    @vitest/coverage-v8@2.0.5, whose vitest peer is 2.0.5):

    • With allowAny: [vitest] / allowedVersions: { vitest: "*" }:
      pnpm peers check does not report the vitest mismatch.
    • Without the rule: ✕ unmet peer vitest — Installed: 5.1.1, Wanted: 2.0.5 (@vitest/coverage-v8@2.0.5).

    So today the rule's only observable effect is suppressing exactly the kind of
    genuine incompatibility the migration should surface — the same reasoning the
    vite path already encodes ("then it only hides real incompatibilities").

    Suggested fix approach (not implemented)

    Mirror the vite treatment for vitest in pnpmPeerDependencyRuleKeys
    (vitest-ecosystem.ts:606):

    1. Since refactor: replace @voidzero-dev/vite-plus-test with upstream vitest #1588 the managed vitest spec is always the real bundled
      VITEST_VERSION (no alias), so a vitestPeerDependencyRuleRequired analog
      is even simpler than the vite one: when the spec is a concrete bundled
      version, the rule is not required for any pnpm version (the override target
      IS vitest, so even pre-10.2 alias-to-peers behavior checks a real version).
    2. Drop vitest from managed and add it to stale in that case, so the
      YAML/JSON writers (catalog.ts:462, mergeManagedPnpmPeerDependencyRules)
      remove a lingering managed rule and pending-detection
      (pnpmPeerDependencyRulesSatisfyVitePlus) stops flagging rule-less
      workspaces as needing an update.
    3. Extend isManagedAllowedVersion to also exempt vitest values other than
      '*', so a user-authored allowedVersions.vitest range is preserved while
      the migration-written '*' is removed (same user-vs-managed distinction the
      vite path makes).
    4. Report the removal like the vite one (report.vitePeerDependencyRuleRemoved
      → analogous vitest line in bin.ts:665) and document it in
      docs/guide/migrate-rules.md.

    Edge cases

    • VITEST_IS_MANAGED_OVERRIDE false (VP_OVERRIDE_PACKAGES without vitest):
      already excluded from managed; unchanged.
    • A !usesVitest workspace already gets vitest in stale — that path is
      kept and becomes the universal behavior.
    • Removal must not delete a user's own vitest entry with a non-'*'
      allowedVersions value (point 3 above) — currently only vite is protected.
    • Workspaces that had real peer warnings before migration (e.g. old
      @vitest/coverage-* pinned to an older line): after the fix, vp migrate
      surfaces them; the migration-rules doc then needs a per-package rule the same
      way it handles incompatible vite plugins.
    • pnpm's peerDependencyRules is deprecated from the 12.17 docs (in favor of
      :peer overrides); pnpm 12.23 still applies it silently, so behavior today is
      unchanged — but it is another reason not to write new managed entries.

    Regression evidence

    Not a regression in the strict sense: behavior is as-designed when #1588 landed
    and #3317 simply did not extend the new "only when needed" policy to vitest.
    The reporter's characterization matches the code exactly.

    Confidence

    high — the failing logic (pnpmPeerDependencyRuleKeys managing vitest
    unconditionally) and its effect on both symptoms are proven by code
    inspection, git history, and direct observation (rule written, re-written after
    removal with "Package manager settings configured", and a real mismatch hidden
    by the rule in the peer-proof scratch project).


    Verification — Issue #3604 (verify stage)

    Claim

    • Observed: on a pnpm workspace that uses Vitest directly, vp migrate
      writes peerDependencyRules: { allowAny: [vitest], allowedVersions: { vitest: "*" } },
      and re-writes it ("Package manager settings configured") after the user
      removes it, because the rule's absence is treated as a pending
      settings update.
    • Expected by reporter: write the vitest rule only when it is needed
      (as migration already does for vite), and leave a workspace without the
      rule alone.

    Verdict

    bug — the behavior is an acknowledged leftover, not a chosen behavior. The
    repository's own design documents say the vitest rule should be removed.

    Evidence

    1. Explicit maintainer intent to remove it (direct evidence).
      rfcs/core-version-alignment.md, "Goals and scope" (lines ~80-87):

      "Out of scope: the vitest peer rule (vitest is pinned to its real
      version, so a follow-up removes the rule) and the preview registry bridge…"

      The core-version-alignment work (PR feat: align the core version with the bundled Vite version #3317, 4dc066a44) deliberately scoped
      the "stop writing the peer rule" change to vite and recorded that the
      vitest rule is equally unnecessary ("pinned to its real version") and
      slated for removal by a follow-up. Issue vp migrate keeps writing a vitest entry into pnpm peerDependencyRules, which hides real peer mismatches, and writes it back after it is removed #3604 is that follow-up; nothing
      landed between feat: align the core version with the bundled Vite version #3317 and current main (5cf0b72c8) that did it.

    2. The rule's original justification is gone. It was introduced with the
      wrapper era: PR fix(cli): add peerDependencyRules for standalone pnpm projects #1222 (487e33891) added pnpm peerDependencyRules because
      peers then resolved to the wrapper aliases (vite → @voidzero-dev/vite-plus-core@1.x,
      vitest → npm:@voidzero-dev/vite-plus-test@latest), whose versions were
      not real Vite/Vitest versions. PR refactor: replace @voidzero-dev/vite-plus-test with upstream vitest #1588 (342fd2f44) deleted the
      vite-plus-test wrapper and pinned vitest to the real bundled
      VITEST_VERSION (packages/cli/src/utils/constants.ts:64), so vitest
      peer ranges are checked against a genuine Vitest version — no pnpm version
      needs the rule (the target of the override is real vitest, so even
      pre-10.2.0 alias-to-peers behavior checks a true version).

    3. The repo's documented policy rejects exactly this rule.
      docs/guide/migrate-rules.md "Peer rules" documents why migration drops the
      vite rule: entries whose pinned version satisfies peers "only hide real
      incompatibilities", and rfcs/core-version-alignment.md states "These rules
      also hide real incompatibilities". pnpm's own docs deprecate
      peerDependencyRules (12.17+) in favor of :peer overrides — the docs'
      recommended remedy for a genuinely incompatible plugin is a per-plugin
      override/rule, not a blanket vitest: '*'. No doc, test intent, or code
      comment anywhere states that Vitest-using workspaces should keep a managed
      vitest peer rule.

    4. Empirically the rule only hides real mismatches (peer-proof scratch,
      see diagnosis): @vitest/coverage-v8@2.0.5 (peer vitest 2.0.5) against
      bundled vitest 5.1.1 is reported by pnpm peers check without the rule
      and silently accepted with it — the exact outcome the vite removal was
      designed to restore.

    5. The re-writing behavior follows mechanically from
      pnpmPeerDependencyRuleKeys keeping vitest in managed
      (vitest-ecosystem.ts:606-626) plus
      pnpmPeerDependencyRulesSatisfyVitePlus
      (vite-plus-bootstrap.ts:209-222) requiring every managed key to be
      present; it is not separately intended behavior. The !usesVitest stale
      path already removes a lingering vitest rule, showing migration itself
      treats the rule as a managed artifact, not a user need.

    6. Tests/snapshots do not encode an intent to keep it. The
      vite-peer-dependency-rule.spec.ts suite (added with feat: align the core version with the bundled Vite version #3317) tests only the
      vite rule; the vitest entries in other fixtures
      (migrator.spec.ts:3040/4329/4457, snapshot migration_vitest_peer_dep.md)
      record the current output rather than assert a requirement, and predate
      (fix(cli): add peerDependencyRules for standalone pnpm projects #1222/refactor: replace @voidzero-dev/vite-plus-test with upstream vitest #1588) or are orthogonal to (feat: align the core version with the bundled Vite version #3317) the "rule only when needed"
      policy. A behavior change here regenerates those snapshots, as feat: align the core version with the bundled Vite version #3317 itself
      did for vite.

    7. Prior discussions: gh search for "peerDependencyRules vitest" /
      "vitest peer rule" finds only issue vp migrate keeps writing a vitest entry into pnpm peerDependencyRules, which hides real peer mismatches, and writes it back after it is removed #3604 itself; PRs fix(cli): add peerDependencyRules for standalone pnpm projects #1222, refactor: replace @voidzero-dev/vite-plus-test with upstream vitest #1588, feat: align the core version with the bundled Vite version #3317
      (bodies checked) never defend keeping the vitest rule for Vitest-using
      workspaces after the wrapper was deleted.

    Confidence

    high — the design RFC explicitly designates the vitest peer rule as
    something "a follow-up removes", the rule's original purpose demonstrably
    disappeared in #1588, the repo's documented policy ("such rules only hide real
    incompatibilities") contradicts writing it, and both reported symptoms were
    reproduced and traced to unambiguous code paths.


    Fix — Issue #3604 (fix stage)

    Rationale

    Follow-up the design RFC asked for (rfcs/core-version-alignment.md, "Out of
    scope: the vitest peer rule (vitest is pinned to its real version, so a
    follow-up removes the rule)"): mirror the vite "rule only when needed" policy
    for vitest. Since the @voidzero-dev/vite-plus-test wrapper was deleted
    (#1588), the managed vitest spec is the real bundled Vitest version, so pnpm
    checks vitest peer ranges against a genuine version — the rule can only hide
    real incompatibilities, and its absence must not be reported as a pending
    settings update.

    Changed files

    • packages/cli/src/migration/migrator/shared.ts — new
      vitestPeerDependencyRuleRequired(spec) next to
      vitePeerDependencyRuleRequired: the rule is required unless the spec is a
      plain, stable semver version (a wrapper alias, dist-tag, file:/URL spec, or
      prerelease/build still needs it).
    • packages/cli/src/migration/migrator/vitest-ecosystem.ts —
      pnpmPeerDependencyRuleKeys now drops vitest from managed and adds it to
      stale whenever the rule is not required (also for Vitest-using workspaces);
      isManagedAllowedVersion treats a non-'*' allowedVersions.vitest as the
      user's own constraint, exactly as for vite.
    • packages/cli/src/migration/migrator/catalog.ts —
      trackVitePeerDependencyRuleRemoval generalized to
      trackPeerDependencyRuleRemoval, which records removals of both managed
      rules in the report.
    • packages/cli/src/migration/migrator/orchestrators.ts,
      packages/cli/src/migration/migrator/vite-plus-bootstrap.ts — renamed the
      three tracker call sites accordingly.
    • packages/cli/src/migration/report.ts — new
      vitestPeerDependencyRuleRemoved flag.
    • packages/cli/src/migration/bin.ts — migrate summary names the removed
      vitest rule, mirroring the vite line.
    • docs/guide/migrate-rules.md — new "Vitest peer rule" documentation; the
      per-package-override note now covers both plain keys.
    • packages/cli/src/migration/__tests__/vite-peer-dependency-rule.spec.ts —
      regression tests (below).
    • 25 regenerated CLI snapshots under
      crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/*/snapshots/.

    No writer or detection call site needed changes: the pnpm-workspace.yaml writer,
    mergeManagedPnpmPeerDependencyRules, and
    pnpmPeerDependencyRulesSatisfyVitePlus all derive their behavior from
    pnpmPeerDependencyRuleKeys, so a rule-less Vitest workspace is no longer
    pending and a lingering managed rule is removed everywhere (workspace yaml, and
    package.json#pnpm on pnpm before 10.6.2).

    Regression tests

    vite-peer-dependency-rule.spec.ts (all fail without the source fix, verified
    by stashing the source changes):

    • vitestPeerDependencyRuleRequired table: 5.1.1/5.2.0 → not required;
      prerelease/build/wrapper-alias/latest/file:/undefined → required.
    • pnpm vitest peer rule > with a stable core version:
      • "removes the vitest rule from a Vitest-using workspace and reports it"
        (the report flag is set, detectVitePlusBootstrapPending flips to false,
        second bootstrap is a no-op);
      • "does not write a vitest rule for a Vitest-using workspace without one"
        (regression for symptom 2: a rule-less workspace is converged, not pending);
      • "keeps a user vitest range while removing the managed entries"
        (allowedVersions: { vitest: '4 || 5' } survives, allowAny entry and
        '*' value go).
    • pnpm vitest peer rule > with a non-stable managed vitest spec:
      "keeps writing the vitest rule" (prerelease pin 5.2.0-beta.1).

    The pre-existing test "deletes peerDependencyRules from pnpm-workspace.yaml
    when no rule remains" now covers the usesVitest case implicitly (both rules go).

    Validation

    • pnpm -F vite-plus build after each source change (the snapshot runner
      validates dist freshness).
    • Regression test red/green: git stash of the source changes → 12 new
      assertions fail; restored → all pass.
    • pnpm -F vite-plus exec vitest run src/migration: 2351 passed, 51 failed —
      identical failure set to the pristine-checkout baseline
      (vitest-v5.spec.ts / vitest-v5-lockfile.spec.ts versioned-preflight
      failures reproduce on unmodified main in this environment; unrelated to
      peer rules). +12 tests vs. baseline, all passing.
    • pnpm -F vite-plus exec tsc --noEmit -p tsconfig.json: clean.
    • vp check: formatting clean; 105 lint errors — exactly the pristine
      baseline count (pre-existing docs/.vitepress/config.mts etc.), none in
      changed files.
    • just snapshot-test migration (compare mode, final build): 350 passed,
      0 failed. 25 snapshots regenerated with UPDATE_SNAPSHOTS=1 and reviewed:
      the diff is only (a) the vitest peerDependencyRules block no longer
      written (21 fixtures), (b) the new "Removed vitest …" summary line where a
      legacy rule was removed (7 fixtures), and (c) pnpm 9's package.json rules
      keeping vite (rule still required on pnpm < 10.2.0) while dropping the
      vitest entries.
    • End-to-end with the local registry wrapper
      (node packages/tools/src/local-npm-registry.ts --pack -- vp migrate …),
      in /tmp/vite-plus-triage/gh-3604/repro-fixed and repro-final*:
      1. fresh migrate of the issue's reproduction writes NO peerDependencyRules;
        pnpm peers check clean;
      2. re-migrate with no rule: "This project is already using Vite+!" — no
        "Package manager settings configured", no rule written (symptom 2 fixed);
      3. a workspace carrying the rule from the previous vite-plus release: the
        rule is removed and the summary names it;
      4. re-migrate afterwards: converged.
    • Control (non-Vitest workspace): converged, no rule, unchanged behavior.

    Skipped checks

    • pnpm test / pnpm bootstrap-cli full suite: the change is confined to
      vp migrate (no vp create code path or non-migration snapshot references
      peerDependencyRules), the migration unit suite and all 350 migration
      snapshot trials pass, and the remaining migration-adjacent suites
      (just check, Rust crates) are untouched by a TypeScript CLI change.
    • The two pre-existing vitest-v5* spec failures are left as-is (they fail on
      pristine main here; out of scope).

    Alternatives considered

    • Dropping the vitest rule unconditionally (no required condition): rejected —
      with a VP_OVERRIDE_PACKAGES wrapper alias, dist-tag, file:/URL, or
      prerelease managed spec (dev/CI and preview flows), peer ranges really do
      fail and the rule is still needed; the condition mirrors vite exactly.
    • A pnpm-version condition like vite's (pre-10.2 alias-to-peers): not needed —
      the vitest override target is a real vitest version, so even pre-10.2 pnpm
      checks a true version; latest/alias specs are covered by the spec check.
    • Extending the change to the @vitest/browser key
      (managedOverridePackages adds it for webdriverio projects): left out of
      scope — the issue concerns vitest only, and that pin is also a real version
      but touches browser-provider fixtures beyond this fix.

    This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.

    I've opened a pull request with this fix: #3606

  3. added
    - P3: minor bug
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugtriage: fix verified

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Target date

    None yet

    Start date

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions