Skip to content

[rush] Fix sync-back when dependencies move to devDependencies#5811

Open
ericprestemon wants to merge 1 commit into
microsoft:mainfrom
ericprestemon:fix/detect-dependencies-moved-to-dev-deps
Open

[rush] Fix sync-back when dependencies move to devDependencies#5811
ericprestemon wants to merge 1 commit into
microsoft:mainfrom
ericprestemon:fix/detect-dependencies-moved-to-dev-deps

Conversation

@ericprestemon
Copy link
Copy Markdown
Contributor

Summary

When a project dependency is moved from dependencies to devDependencies, rush update would correctly update the temporary lockfile but fail to sync it back to common/config/rush/. This left the
repository with a stale committed lockfile despite the install appearing to succeed.

Details

The root cause was an unconditional fall-through in isWorkspaceProjectModifiedAsync (the PNPM v8+ logic path). When checking a project's devDependencies, if a package was missing from the lockfile's
devDependencies section, the code would automatically check the dependencies section instead.

While this fall-through is necessary to support dual-declarations (which PNPM collapses into the dependencies section of the lockfile), it was also masking the case where a package had been moved out of the
regular dependencies section entirely.

The fix introduces a regularDependencyNames set for the project and gates the fall-through on membership in that set. This preserves support for dual-declared packages while correctly identifying a stale
lockfile when a package has been moved to devDependencies.

How it was tested

  • Added a regression test in PnpmShrinkwrapFile.test.ts.
  • Created a new test fixture stale-dev-in-dependencies.yaml that simulates a lockfile where a moved dependency is still incorrectly listed in the dependencies section.
  • Verified that the new test fails without the fix and passes with it.
  • Ran the full rush-lib test suite to ensure no regressions in other lockfile sync scenarios.

'rush update' failed to sync back the corrected pnpm-lock.yaml when a dependency moved to devDependencies because
isWorkspaceProjectModifiedAsync would unconditionally fall through to the 'dependencies' section if a package was
missing from 'devDependencies'.

This fall-through is now gated on the new set regularDependencyNames to support legitimate dual-declarations while
correctly detecting when a dependency has been moved out of the 'dependencies' section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

1 participant