[rush-lib] Add async APIs for disk-touching methods in PackageJsonEditor, CommonVersionsConfiguration, and VersionPolicy#5724
Merged
iclanton merged 5 commits intomicrosoft:mainfrom Mar 25, 2026
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4d56b0e to
fcd395a
Compare
bmiddha
approved these changes
Mar 25, 2026
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
Adds async variants of disk-touching methods across several
rush-libAPIs and deprecates the corresponding synchronous methods. This is part of an ongoing effort to asyncify the Rush codebase to improve performance and avoid blocking the event loop.Affected classes:
PackageJsonEditor: addsloadAsync,saveIfModifiedAsync; deprecatesload,saveIfModifiedCommonVersionsConfiguration: addsloadFromFileAsync,saveAsync; deprecatesloadFromFile,saveVersionPolicy: addssetDependenciesBeforePublishAsync,setDependenciesBeforeCommitAsync; deprecatessetDependenciesBeforePublish,setDependenciesBeforeCommitAlso includes a constructor refactor for
PackageJsonEditorthat replaces pre-initialized emptyMaps +forEach/.set()patterns with directnew Map(entries.map(...))assignments, and replacesObject.prototype.hasOwnProperty.call(x, key)checks withSet.has()lookups.Details
The sync methods are preserved with
@deprecatedJSDoc tags pointing to their async replacements to maintain backwards compatibility. The new async methods useJsonFile.loadAsync,JsonFile.saveAsync, andJsonFile.loadAndValidateAsyncfrom@rushstack/node-core-library.The
VersionPolicyshared logic was extracted into two private helper functions (updateDependenciesBeforePublish,updateDependenciesBeforeCommit) to avoid duplicating the dependency-update traversal between sync and async variants.How it was tested
Existing unit tests pass. The async paths follow the same logic as the tested sync paths and use the same underlying
JsonFileasync APIs used elsewhere in the codebase.