Skip to content

fix: write pnpm overrides to pnpm-workspace.yaml#24918

Open
mcollovati wants to merge 3 commits into
mainfrom
fix/pnpm-11-workspace-overrides
Open

fix: write pnpm overrides to pnpm-workspace.yaml#24918
mcollovati wants to merge 3 commits into
mainfrom
fix/pnpm-11-workspace-overrides

Conversation

@mcollovati

Copy link
Copy Markdown
Collaborator

Recent pnpm versions no longer read the "pnpm" field from package.json, so the dependency overrides Flow generated there were silently ignored and pnpm logged a warning about it. As a result Flow could no longer lock transitive dependencies to the platform versions when using pnpm.

Flow now writes these overrides to pnpm-workspace.yaml, the location pnpm actually reads, and moves any overrides left in package.json over to it. Existing user content in pnpm-workspace.yaml is preserved, and a Flow-generated file is cleaned up like other generated frontend files.

@github-actions github-actions Bot added the +0.0.1 label Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Test Results

 1 457 files  +1   1 457 suites  +1   1h 45m 43s ⏱️ + 6m 7s
10 314 tests +8  10 246 ✅ +8  68 💤 ±0  0 ❌ ±0 
10 786 runs  +8  10 717 ✅ +8  69 💤 ±0  0 ❌ ±0 

Results for commit 0ac9425. ± Comparison against base commit 1ac6a6e.

♻️ This comment has been updated with latest results.

@mcollovati mcollovati force-pushed the fix/pnpm-11-workspace-overrides branch from b64076e to 19e6b57 Compare July 6, 2026 11:01
Recent pnpm versions no longer read the "pnpm" field from package.json,
so the dependency overrides Flow generated there were silently ignored
and pnpm logged a warning about it. As a result Flow could no longer
lock transitive dependencies to the platform versions when using pnpm.

Flow now writes these overrides to pnpm-workspace.yaml, the location
pnpm actually reads, and moves any overrides left in package.json over
to it. Existing user content in pnpm-workspace.yaml is preserved, and a
Flow-generated file is cleaned up like other generated frontend files.
Override processing was split into `lockNpmOverrides` and `lockPnpmOverrides`,
suggesting the two package managers were handled differently when in fact only
the override storage format and location differ.

`lockVersionForNpm` now manages overrides as a single canonical flat map and
branches only to load and save them, delegating the format differences to an
`OverridesStore` (nested `overrides` in package.json for npm, flat overrides in
pnpm-workspace.yaml for pnpm). Behavior is unchanged.
assertNotNull(npmPackageJson.get(OVERRIDES),
"npm overrides must be written to package.json");
assertTrue(npmPackageJson.get(OVERRIDES).has(TEST_DEPENDENCY),
"Managed override must be present in npm overrides");

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.

This is maybe also expected to delete the obsolete pnpm-workspace.yaml, given that both conditions apply:

  • overrides are migrated to the npm'spackage.json convention
  • there's no other user content besides overrides is in pnpm-workspace.yaml

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Could it be that the user added custom entries in the workspace file and wants to preserve them?
Is this a valid use case?

"User packages section must be preserved");
assertTrue(content.contains("shamefully-hoist"),
"User settings must be preserved");
assertTrue(content.contains("dep"), "Override must be written");

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.

In addition, let us assert that the user content is preserved after clearing overrides with workspace.setOverrides(Map.of());. Use case: migrating to npm.

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

Projects

Status: 🔎Iteration reviews

Development

Successfully merging this pull request may close these issues.

2 participants