[rush] Fix sync-back when dependencies move to devDependencies#5811
Open
ericprestemon wants to merge 1 commit into
Open
[rush] Fix sync-back when dependencies move to devDependencies#5811ericprestemon wants to merge 1 commit into
ericprestemon wants to merge 1 commit into
Conversation
'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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a project dependency is moved from
dependenciestodevDependencies,rush updatewould correctly update the temporary lockfile but fail to sync it back tocommon/config/rush/. This left therepository 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'sdevDependencies, if a package was missing from the lockfile'sdevDependenciessection, the code would automatically check thedependenciessection instead.While this fall-through is necessary to support dual-declarations (which PNPM collapses into the
dependenciessection of the lockfile), it was also masking the case where a package had been moved out of theregular
dependenciessection entirely.The fix introduces a
regularDependencyNamesset for the project and gates the fall-through on membership in that set. This preserves support for dual-declared packages while correctly identifying a stalelockfile when a package has been moved to
devDependencies.How it was tested
PnpmShrinkwrapFile.test.ts.stale-dev-in-dependencies.yamlthat simulates a lockfile where a moved dependency is still incorrectly listed in thedependenciessection.rush-libtest suite to ensure no regressions in other lockfile sync scenarios.