microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.74k stars 587 forks source link

[rush] Add a logic to remove out of date .pnpm-sync.json file during rush install or update #4793

Closed g-chao closed 2 weeks ago

g-chao commented 2 weeks ago

Summary

  1. Add a logic to remove out of date .pnpm-sync.json file during rush install or update
  2. Upgrade pnpm-sync-lib to 0.2.8

Details

Problem

Normally, when users upgrade rush engine version, it won't clear the all existing node_modules cache, and rush will reuse these node_modules cache during rush install/update. This could sometime causes a problem for pnpm-sync. Since .pnpm-sync.json is versioned, it should be regenerated even though the installation is up to date.

Also, in real practice, if a Monorepo is using feature based development flow, different branches can has different rush engine version, and if you switch between these branches, the node_modules won't be cleared and rush will try to resue the installation cache as well. This will also causes the problem that installation is up to date but .pnpm-sync.json is out of date.

These problems can be solved by rush purge, this will clear all node_modules folder, this action is expensive, though it is the correct way to do.

Solution

We can reposition the logic to generate the .pnpm-sync.json during rush install/update to solve the problem. Now, .pnpm-sync.json will be ALWAYS regenerated no matter the rush install/update is skipped or not. In addition, every rush install/update action, we also check if there are out of date .pnpm-sync.json files, if yes, remove them.

How it was tested

Impacted documentation

octogonz commented 2 weeks ago

@g-chao we'll publish this separately after PR #4735 is released.