Skip to content

pnpm monorepo: duplicate vite/vitest instances cause vp test cache misses #1932

Description

@fengmk2

Under pnpm, vp create vite:monorepo resolves vite-plus / vite / vitest to 2 instances each. The duplicate vitest runs an upstream vite that lacks the @voidzero-dev/vite-task-client integration, so vp test's config temp file (node_modules/.vite-temp/vite.config.ts.timestamp-*.mjs) is tracked as a modified input and utils#test never caches. This failed "Verify cache (monorepo only)" (80% not 100%) in #1774.

vp why in the created monorepo (pnpm)

$ vp why vite-plus
vite-plus@0.0.0 peer#49d3 (2 variations)
├── test-project@0.0.0 (devDependencies)   # root  -> on upstream vite
└── utils@0.0.0 (devDependencies)           # utils -> on upstream vite

vite-plus@0.0.0 peer#6072 (2 variations)
└── website@0.0.0 (devDependencies)         # website -> on core (has a direct vite dep)

Found 1 version, 2 instances of vite-plus

$ vp why vitest
Found 1 version, 2 instances of vitest

$ vp why vite
Found 1 version of @voidzero-dev/vite-plus-core   # the override target
Found 1 version of vite                            # a 2nd, upstream vite

Why

  • vitest has a required peer vite: ^6 || ^7 || ^8. The vite override (to @voidzero-dev/vite-plus-core) only rewrites real vite dependency edges, and the override target (core@0.0.0) can't satisfy that range.
  • The workspace root and packages/utils depend on vite-plus (→ vitest) but have no direct vite, so there is no edge to override. With pnpm's default autoInstallPeers, pnpm installs an upstream vite to satisfy the peer, splitting the graph.
  • apps/website keeps a direct vite devDep, so its override edge binds vitest's peer to core. npm/yarn/bun dedupe transitive/peer vite tree-wide, so only pnpm is affected.

Proposed fix

For pnpm, add a direct vite dep (the override target) to the workspace root and packages/utils (mirroring apps/website). Verified: dedupes all three to a single instance and vp run ready reaches 100% with default pnpm settings.

Workaround in #1774

PNPM_CONFIG_MINIMUM_RELEASE_AGE=0 in test-vp-create.yml so vitest resolves vite@8.1.0 (which carries the integration). CI-only band-aid; real users on the default age gate still hit the duplicate-instance miss until this fix lands.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Priority

High

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions