[rush-resolver-cache] Fix subpackage cache optimization #5335
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
Fixes an issue where the subpackage cache file was accidentally written empty.
Details
The previous fix wrote the file before the data had been populated, making the optimization produce correct results but be useless.
Updates the caching layer in PnpmShrinkwrapFile to be based on a content hash of the raw shrinkwrap text instead of file path, so that writing a new file will never have caching issues.
Added an explicit API to clear the shrinkwrap cache.
How it was tested
Built and copied into a repository using the feature. Validated resolver cache created correctly.
Impacted documentation
Only the API documentation for PnpmShrinkwrapFile, which doesn't seem to be part of the API.md.