Skip to content

vp migrate: @vitest/* not consistently catalog-referenced in catalog-managed projects #2005

Description

@fengmk2

Problem

When migrating a project that uses a pnpm default catalog: for its toolchain, vp migrate handles @vitest/* inconsistently with vitest:

  • It injects a browser provider (@vitest/browser-playwright) into the catalog, but references it as a concrete version in package.json instead of catalog:, leaving that catalog entry unused.
  • It aligns a pre-existing @vitest/* (@vitest/coverage-v8) to the bundled version as a concrete spec and does not move it into the catalog, even though vitest itself is catalog:.

Net effect: vitest is catalog:, but the @vitest/* packages are concrete, and one of them also carries a dead catalog entry.

Reproduction

fengmk2/npmx.dev#27, migrated with vite-plus 0.0.0-commit.fcd4a979bd79b8328dd3318e451fc135242c0e4b.

pnpm-workspace.yaml:

catalog:
  vitest: 4.1.9
  '@vitest/browser-playwright': 4.1.9   # added by migrate

root package.json:

{
  "vitest": "catalog:",
  "@vitest/browser-playwright": "4.1.9",  // concrete, should be "catalog:"
  "@vitest/coverage-v8": "4.1.9"          // concrete, not in the catalog
}

The catalog's @vitest/browser-playwright entry is referenced by no package.

Expected

docs/guide/migrate-rules.md states: "When migration injects a provider into a catalog-capable project, it uses the preferred catalog and adds the provider at the bundled Vitest version." So:

  1. Bug: @vitest/browser-playwright should be catalog: in package.json (matching the catalog entry the migrate already created), not a concrete spec.
  2. Consistency: for a catalog-managed toolchain, aligned lockstep @vitest/* (e.g. @vitest/coverage-v8) arguably belong in the catalog too, referenced via catalog:, rather than a concrete spec that duplicates the version the catalog already tracks for vitest.

Suggested fix

  • When injecting a browser provider into a catalog-capable project, write catalog: in package.json (the catalog entry is already added).
  • Consider catalog-izing aligned @vitest/* lockstep packages when the toolchain is catalog-managed, so vitest and its ecosystem share one source of truth.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions