Skip to content

Commit dffa822

Browse files
authored
Merge pull request microsoft#1604 from D4N14L/danade/fixUnmetPeerDependencyDuringLink
Fix unmet peer dependency error when strictPeerDependencies is false
2 parents 3b5b888 + a7034db commit dffa822

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

apps/rush-lib/src/api/RushConfigurationProject.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ export class RushConfigurationProject {
167167
return this._projectRushTempFolder;
168168
}
169169

170+
/**
171+
* The Rush configuration for the monorepo that the project belongs to.
172+
*/
173+
public get rushConfiguration(): RushConfiguration {
174+
return this._rushConfiguration;
175+
}
176+
170177
/**
171178
* The review category name, or undefined if no category was assigned.
172179
* This name must be one of the valid choices listed in RushConfiguration.reviewCategories.

apps/rush-lib/src/logic/pnpm/PnpmProjectDependencyManifest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ export class PnpmProjectDependencyManifest {
194194
const topLevelDependencySpecifier: DependencySpecifier | undefined =
195195
this._pnpmShrinkwrapFile.getTopLevelDependencyVersion(peerDependencyName);
196196
if (!topLevelDependencySpecifier || !semver.valid(topLevelDependencySpecifier.versionSpecifier)) {
197-
throw new InternalError(
197+
const errorMessage: string =
198198
`Could not find peer dependency '${peerDependencyName}' that satisfies version '${dependencySemVer}'`
199-
);
199+
if (this._project.rushConfiguration.pnpmOptions && this._project.rushConfiguration.pnpmOptions.strictPeerDependencies) {
200+
throw new InternalError(errorMessage);
201+
}
202+
console.log(`${errorMessage}, skipping...`);
203+
continue;
200204
}
201205

202206
this._addDependencyInternal(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Log to console instead of throwing when an unmet peer dependency is encountered during linking, and strictPeerDependencies is false",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "3473356+D4N14L@users.noreply.github.com"
11+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ export class RushConfigurationProject {
332332
readonly projectRelativeFolder: string;
333333
readonly projectRushTempFolder: string;
334334
readonly reviewCategory: string;
335+
readonly rushConfiguration: RushConfiguration;
335336
readonly shouldPublish: boolean;
336337
readonly skipRushCheck: boolean;
337338
readonly tempProjectName: string;

0 commit comments

Comments
 (0)