[rush] Add an option to make the Rush operation hash depend on the NodeJS version.#5630
Merged
iclanton merged 2 commits intomicrosoft:mainfrom Feb 18, 2026
Merged
Conversation
…h-project.json Add a new boolean `dependsOnNodeVersion` property to operation settings in rush-project.json. When set to true, the Node.js version (process.version) is included in the build cache hash, ensuring cached outputs are invalidated when the Node.js version changes. This is useful for projects that produce Node.js-version-specific outputs, such as native module builds.
…nNodeVersion Extend dependsOnNodeVersion from a simple boolean to also accept 'major', 'minor', or 'patch' string values (with true as an alias for 'patch'). - 'major': hash includes only major version (e.g. 18) - 'minor': hash includes major.minor (e.g. 18.17) - 'patch'/true: hash includes full version (e.g. 18.17.1) Extract NodeVersionGranularity type alias for reuse. Pre-compute version strings at all granularity levels once per InputsSnapshot construction.
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
Add a
dependsOnNodeVersionsetting toconfig/rush-project.jsonthat allows a project's build cache hash to incorporate the Node.js version. This ensures that projects whose build output varies by Node version get correct cache hits/misses.Two motivating scenarios:
Details
A new
dependsOnNodeVersionproperty is added tooperationSettingsinrush-project.json. It accepts:true- include the full patch version (e.g.24.13.0) in the cache hash (alias for"patch")"major"- include only the major version (e.g.24)"minor"- include the major.minor version (e.g.24.13)"patch"- include the full major.minor.patch version (e.g.24.13.0)The granularity options let teams choose the right cache invalidation tradeoff. For example,
"major"avoids unnecessary rebuilds between patch or minor Node versions, while"patch"ensures exact reproducibility.Implementation:
rush-project.schema.jsonwith aoneOfacceptingtrueor a string enumNodeVersionGranularitytype alias ('major' | 'minor' | 'patch') toIOperationSettingsand exported it fromrush-libInputsSnapshotto pre-compute Node version strings for all granularities once in the constructor, and include the appropriate string ingetOperationOwnStateHash()when the setting is presentHow it was tested
Added unit tests to
InputsSnapshot.test.tscovering:dependsOnNodeVersion: true, each granularity level ("major","minor","patch"), equivalence oftrueand"patch", and the default case (no Node version in hash)Impacted documentation
dependsOnNodeVersionproperty inoperationSettings)rush-lib/src/schemas/rush-project.schema.json