8000 Setting to avoid manually configuring decoupledLocalDependencies acro… · OlliMartin/rushstack@bd759e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd759e4

Browse files
authored
Setting to avoid manually configuring decoupledLocalDependencies across subspaces (microsoft#5072)
Co-authored-by: Lincoln <L-Qun@users.noreply.github.com>
1 parent e5560f2 commit bd759e4

File tree

7 files changed

+57
-5
lines changed

7 files changed

+57
-5
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Add a configuration option to avoid manually configuring decoupledLocalDependencies across subspaces.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

common/config/rush/experiments.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,13 @@
108108
* When this toggle is enabled, Rush will only scan specific paths, significantly speeding up Git operations.
109109
*/
110110
// "enableSubpathScan": true
111+
112+
/**
113+
* Rush has a policy that normally requires Rush projects to specify `workspace:*` in package.json when depending
114+
* on other projects in the workspace, unless they are explicitly declared as `decoupledLocalDependencies`
115+
* in rush.json. Enabling this experiment will remove that requirement for dependencies belonging to a different
116+
* subspace. This is useful for large product groups who work in separate subspaces and generally prefer to consume
117+
* each other's packages via the NPM registry.
118+
*/
119+
// "exemptDecoupledDependenciesBetweenSubspaces": true
111120
}

common/reviews/api/rush-lib.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ export interface IExperimentsJson {
482482
buildSkipWithAllowWarningsInSuccessfulBuild?: boolean;
483483
cleanInstallAfterNpmrcChanges?: boolean;
484484
enableSubpathScan?: boolean;
485+
exemptDecoupledDependenciesBetweenSubspaces?: boolean;
485486
forbidPhantomResolvableNodeModulesFolders?: boolean;
486487
generateProjectImpactGraphDuringRushUpdate?: boolean;
487488
noChmodFieldInTarHeaderNormalization?: boolean;

libraries/rush-lib/assets/rush-init/common/config/rush/experiments.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,14 @@
108108
* By default, rush perform a full scan of the entire repository. For example, Rush runs `git status` to check for local file changes.
109109
* When this toggle is enabled, Rush will only scan specific paths, significantly speeding up Git operations.
110110
*/
111-
/*[LINE "HYPOTHETICAL"]*/ "enableSubpathScan": true
111+
/*[LINE "HYPOTHETICAL"]*/ "enableSubpathScan": true,
112+
113+
/**
114+
* Rush has a policy that normally requires Rush projects to specify `workspace:*` in package.json when depending
115+
* on other projects in the workspace, unless they are explicitly declared as `decoupledLocalDependencies`
116+
* in rush.json. Enabling this experiment will remove that requirement for dependencies belonging to a different
117+
* subspace. This is useful for large product groups who work in separate subspaces and generally prefer to consume
118+
* each other's packages via the NPM registry.
119+
*/
120+
/*[LINE "HYPOTHETICAL"]*/ "exemptDecoupledDependenciesBetweenSubspaces": false
112121
}

libraries/rush-lib/src/api/ExperimentsConfiguration.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ export interface IExperimentsJson {
119119
* When this toggle is enabled, Rush will only scan specific paths, significantly speeding up Git operations.
120120
*/
121121
enableSubpathScan?: boolean;
122+
123+
/**
124+
* Rush has a policy that normally requires Rush projects to specify `workspace:*` in package.json when depending
125+
* on other projects in the workspace, unless they are explicitly declared as `decoupledLocalDependencies`
126+
* in rush.json. Enabling this experiment will remove that requirement for dependencies belonging to a different
127+
* subspace. This is useful for large product groups who work in separate subspaces and generally prefer to consume
128+
* each other's packages via the NPM registry.
129+
*/
130+
exemptDecoupledDependenciesBetweenSubspaces?: boolean;
122131
}
123132

124133
const _EXPERIMENTS_JSON_SCHEMA: JsonSchema = JsonSchema.fromLoadedObject(schemaJson);

libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,19 @@ export class WorkspaceInstallManager extends BaseInstallManager {
223223
const dependencySpecifier: DependencySpecifier = new DependencySpecifier(name, version);
224224

225225
// Is there a locally built Rush project that could satisfy this dependency?
226-
const referencedLocalProject: RushConfigurationProject | undefined =
226+
let referencedLocalProject: RushConfigurationProject | undefined =
227227
this.rushConfiguration.getProjectByName(name);
228228

229+
// If we enable exemptDecoupledDependenciesBetweenSubspaces, it will only check dependencies within the subspace.
230+
if (
231+
this.rushConfiguration.experimentsConfiguration.configuration
232+
.exemptDecoupledDependenciesBetweenSubspaces
233+
) {
234+
if (referencedLocalProject && !subspace.contains(referencedLocalProject)) {
235+
referencedLocalProject = undefined;
236+
}
237+
}
238+
229239
// Validate that local projects are referenced with workspace notation. If not, and it is not a
230240
// cyclic dependency, then it needs to be updated to specify `workspace:*` explicitly. Currently only
231241
// supporting versions and version ranges for specifying a local project.
@@ -248,9 +258,9 @@ export class WorkspaceInstallManager extends BaseInstallManager {
248258
// eslint-disable-next-line no-console
249259
console.log(
250260
Colorize.red(
251-
`"${rushProject.packageName}" depends on package "${name}" (${version}) which exists ` +
252-
'within the workspace but cannot be fulfilled with the specified version range. Either ' +
253-
'specify a valid version range, or add the package as a cyclic dependency.'
261+
`"${rushProject.packageName}" depends on package "${name}" (${version}) which belongs to ` +
262+
'the workspace but cannot be fulfilled with the specified version range. Either ' +
263+
'specify a valid version range, or add the package to "decoupledLocalDependencies" in rush.json.'
254264
)
255265
);
256266
throw new AlreadyReportedError();

libraries/rush-lib/src/schemas/experiments.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
"enableSubpathScan": {
7878
"description": "By default, rush perform a full scan of the entire repository. For example, Rush runs `git status` to check for local file changes. When this toggle is enabled, Rush will only scan specific paths, significantly speeding up Git operations.",
7979
"type": "boolean"
80+
},
81+
"exemptDecoupledDependenciesBetweenSubspaces": {
82+
"description": "Rush has a policy that normally requires Rush projects to specify `workspace:*` in package.json when depending on other projects in the workspace, unless they are explicitly declared as `decoupledLocalDependencies in rush.json. Enabling this experiment will remove that requirement for dependencies belonging to a different subspace. This is useful for large product groups who work in separate subspaces and generally prefer to consume each other's packages via the NPM registry.",
83+
"type": "boolean"
8084
}
8185
},
8286
"additionalProperties": false

0 commit comments

Comments
 (0)
0