Skip to content

Commit 372e60c

Browse files
committed
Add an option to disable the per-project shrinkwrap.
1 parent af79a67 commit 372e60c

6 files changed

Lines changed: 35 additions & 7 deletions

File tree

‎apps/rush-lib/assets/rush-init/rush.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@
6161
* After modifying this field, it's recommended to run "rush update --full" so that the package manager
6262
* will recalculate all version selections.
6363
*/
64-
/*[LINE "HYPOTHETICAL"]*/ "resolutionStrategy": "fast"
64+
/*[LINE "HYPOTHETICAL"]*/ "resolutionStrategy": "fast",
65+
66+
/**
67+
* If set to `true`, don't attempt to generate a file that records the dependencies of each project to
68+
* be used for incremental builds.
69+
*/
70+
/*[LINE "DEMO"]*/ "disablePerProjectDependencyManifest": false
6571
},
6672

6773
/**

‎apps/rush-lib/src/api/RushConfiguration.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export interface IRushRepositoryJson {
8787
export interface IPnpmOptionsJson {
8888
strictPeerDependencies?: boolean;
8989
resolutionStrategy?: ResolutionStrategy;
90+
disablePerProjectDependencyManifest?: boolean;
9091
}
9192

9293
/**
@@ -186,10 +187,17 @@ export class PnpmOptionsConfiguration {
186187
*/
187188
public readonly resolutionStrategy: ResolutionStrategy;
188189

190+
/**
191+
* If set to `true`, don't attempt to generate a file that records the dependencies of each project to be used for
192+
* incremental builds.
193+
*/
194+
public readonly disablePerProjectDependencyManifest: boolean;
195+
189196
/** @internal */
190197
public constructor(json: IPnpmOptionsJson) {
191198
this.strictPeerDependencies = !!json.strictPeerDependencies;
192199
this.resolutionStrategy = json.resolutionStrategy || 'fewer-dependencies';
200+
this.disablePerProjectDependencyManifest = !!json.disablePerProjectDependencyManifest;
193201
}
194202
}
195203

‎apps/rush-lib/src/logic/PackageChangeAnalyzer.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ export class PackageChangeAnalyzer {
104104
* files: {
105105
* "src/index.ts": "478789a7fs8a78989afd8",
106106
* "src/fileOne.ts": "a8sfa8979871fdjiojlk",
107-
* "common/api/review": "324598afasfdsd", // this entry was added by the API Extractor task (for example)
108-
* "node_modules.json": "3428789dsafdsfaf" // this is a file which will be created by rush link describing
109-
* // the state of the node_modules folder
107+
* "common/api/review": "324598afasfdsd", // this entry was added by the API Extractor
108+
* // task (for example)
109+
* ".rush/temp/project-dependencies.json": "3428789dsafdsfaf" // this is a file which will be created by rush
110+
* // link describing the state of the
111+
* // node_modules folder
110112
* }
111113
* }
112114
*
@@ -131,7 +133,10 @@ export class PackageChangeAnalyzer {
131133
// });
132134
// }
133135

134-
if (this._rushConfiguration.packageManager === 'pnpm') {
136+
if (
137+
this._rushConfiguration.packageManager === 'pnpm' &&
138+
!this._rushConfiguration.pnpmOptions.disablePerProjectDependencyManifest
139+
) {
135140
const projects: RushConfigurationProject[] = [];
136141
const projectDependencyManifestPaths: string[] = [];
137142

‎apps/rush-lib/src/logic/pnpm/PnpmLinkManager.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ export class PnpmLinkManager extends BaseLinkManager {
270270
newLocalFolderPath
271271
);
272272

273-
pnpmProjectDependencyManifest.addDependency(newLocalPackage);
273+
if (!this._rushConfiguration.pnpmOptions.disablePerProjectDependencyManifest) {
274+
pnpmProjectDependencyManifest.addDependency(newLocalPackage);
275+
}
274276

275277
newLocalPackage.symlinkTargetFolderPath = dependencyLocalInstallationRealpath;
276278
localPackage.addChild(newLocalPackage);
@@ -282,7 +284,9 @@ export class PnpmLinkManager extends BaseLinkManager {
282284

283285
PnpmLinkManager._createSymlinksForTopLevelProject(localPackage);
284286

285-
pnpmProjectDependencyManifest.save();
287+
if (!this._rushConfiguration.pnpmOptions.disablePerProjectDependencyManifest) {
288+
pnpmProjectDependencyManifest.save();
289+
}
286290

287291
// Also symlink the ".bin" folder
288292
const projectFolder: string = path.join(localPackage.folderPath, 'node_modules');

‎apps/rush-lib/src/schemas/rush.schema.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
"description": "Configures the strategy used to select versions during installation. This feature requires PNPM version 3.1 or newer. It corresponds to the \"--resolution-strategy\" command-line option for PNPM. Possible values are \"fast\" and \"fewer-dependencies\". PNPM's default is \"fast\", but this may be incompatible with certain packages, for example the \"@types\" packages from DefinitelyTyped. Rush's default is \"fewer-dependencies\", which causes PNPM to avoid installing a newer version if an already installed version can be reused; this is more similar to NPM's algorithm.",
6666
"type": "string",
6767
"enum": ["fewer-dependencies", "fast"]
68+
},
69+
"disablePerProjectDependencyManifest": {
70+
"description": "If set to `true`, don't attempt to generate a file that records the dependencies of each project to be used for incremental builds.",
71+
"type": "boolean"
6872
}
6973
},
7074
"additionalProperties": false

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export class PnpmOptionsConfiguration {
219219
//
220220
// @internal
221221
constructor(json: IPnpmOptionsJson);
222+
readonly disablePerProjectDependencyManifest: boolean;
222223
readonly resolutionStrategy: ResolutionStrategy;
223224
readonly strictPeerDependencies: boolean;
224225
}

0 commit comments

Comments
 (0)