Skip to content

Commit faf54e0

Browse files
authored
Implements aggregate peer deps (#5552)
**What's the problem this PR addresses?** The "incompatible peer dependencies" warnings are extremely verbose and hard to work with. They can happen when migrating some common packages (for example React), often aren't that important, and take a lot of vertical space (thus desensitizing users to legit warnings). **How did you fix it?** This PR implements a new warning to replace "incompatible peer dependencies": "incompatible peer dependency aggregates". Yes, it's subtle 😄 The message looks like this: ``` node-notifier is listed by your project with version 5.4.0, which doesn't satisfy what @jest/reporters and other dependencies request (^8.0.1 || ^9.0.0 || ^10.0.0). react is listed by your project with version 18.2.0, which doesn't satisfy what react-highlight-words and other dependencies request (but they have non-overlapping ranges!). ``` Note how Yarn is able to join together all the ranges from all the dependencies (or die trying)! I kept the code for the old incompatible peer dependencies, because I'd like to reference them in the output of `yarn explain peer-requirements` (so that the aggregate's explanation would then reference the individual other warnings). I didn't implement the aggregate explanation yet, though, because I suspect it might require rewriting the command, which will have to be a follow-up. **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent e6b17bf commit faf54e0

File tree

13 files changed

+543
-409
lines changed

13 files changed

+543
-409
lines changed

.yarn/versions/063b606b.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
releases:
2+
"@yarnpkg/cli": minor
3+
"@yarnpkg/core": minor
4+
"@yarnpkg/plugin-git": minor
5+
6+
declined:
7+
- "@yarnpkg/plugin-compat"
8+
- "@yarnpkg/plugin-constraints"
9+
- "@yarnpkg/plugin-dlx"
10+
- "@yarnpkg/plugin-essentials"
11+
- "@yarnpkg/plugin-exec"
12+
- "@yarnpkg/plugin-file"
13+
- "@yarnpkg/plugin-github"
14+
- "@yarnpkg/plugin-http"
15+
- "@yarnpkg/plugin-init"
16+
- "@yarnpkg/plugin-interactive-tools"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-nm"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-pnpm"
25+
- "@yarnpkg/plugin-stage"
26+
- "@yarnpkg/plugin-typescript"
27+
- "@yarnpkg/plugin-version"
28+
- "@yarnpkg/plugin-workspace-tools"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/doctor"
31+
- "@yarnpkg/extensions"
32+
- "@yarnpkg/nm"
33+
- "@yarnpkg/pnpify"
34+
- "@yarnpkg/sdks"

packages/acceptance-tests/pkg-tests-specs/sources/features/peerDependenciesMeta.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe(`Features`, () => {
2929
);
3030

3131
test(
32-
`it should report collapsed mismatched peer dependency warnings when a set of mismatched peerDependency requirements is detected`,
32+
`it should report collapsed a peer dependency warning when a set of mismatched peerDependency requirements is detected`,
3333
makeTemporaryEnv(
3434
{
3535
dependencies: {
@@ -40,7 +40,7 @@ describe(`Features`, () => {
4040
async ({path, run, source}) => {
4141
const {stdout} = await run(`install`);
4242

43-
expect(stdout).toMatch(/provides no-deps \(p[0-9a-f]{5}\) with version 1.1.0, which doesn't satisfy what mismatched-peer-deps-lvl0 and some of its descendants request/);
43+
expect(stdout).toContain(`no-deps is listed by your project with version 1.1.0, which doesn't satisfy what mismatched-peer-deps-lvl0 requests (1.0.0)`);
4444
},
4545
),
4646
);

packages/acceptance-tests/pkg-tests-specs/sources/protocols/__snapshots__/git.test.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`Protocols git: it should resolve a git dependency (git+ssh://[email protected]/yarnpkg/util-deprecate.git#v1.0.1) 1`] = `"util-deprecate@git+ssh://[email protected]/yarnpkg/util-deprecate.git#commit=6e923f7d98a0afbe5b9c7db9d0f0029c1936746c"`;
44

5+
exports[`Protocols git: it should resolve a git dependency (git://github.com/yarnpkg/util-deprecate.git#v1.0.1) 1`] = `"util-deprecate@https://github.com/yarnpkg/util-deprecate.git#commit=6e923f7d98a0afbe5b9c7db9d0f0029c1936746c"`;
6+
57
exports[`Protocols git: it should resolve a git dependency (https://github.com/yarnpkg/util-deprecate.git#b3562c2798507869edb767da869cd7b85487726d) 1`] = `"util-deprecate@https://github.com/yarnpkg/util-deprecate.git#commit=b3562c2798507869edb767da869cd7b85487726d"`;
68

79
exports[`Protocols git: it should resolve a git dependency (https://github.com/yarnpkg/util-deprecate.git#master) 1`] = `"util-deprecate@https://github.com/yarnpkg/util-deprecate.git#commit=4bcc600d20e3a53ea27fa52c4d1fc49cc2d0eabb"`;

packages/plugin-git/sources/GitFetcher.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@ export class GitFetcher implements Fetcher {
1717

1818
async fetch(locator: Locator, opts: FetchOptions) {
1919
const expectedChecksum = opts.checksums.get(locator.locatorHash) || null;
20-
const normalizedLocator = gitUtils.normalizeLocator(locator);
2120

2221
const checksums = new Map(opts.checksums);
23-
checksums.set(normalizedLocator.locatorHash, expectedChecksum);
22+
checksums.set(locator.locatorHash, expectedChecksum);
2423
const nextOpts = {...opts, checksums};
2524

26-
const result = await this.downloadHosted(normalizedLocator, nextOpts);
25+
const result = await this.downloadHosted(locator, nextOpts);
2726
if (result !== null)
2827
return result;
2928

3029
const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(locator, expectedChecksum, {
3130
onHit: () => opts.report.reportCacheHit(locator),
3231
onMiss: () => opts.report.reportCacheMiss(locator, `${structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the remote repository`),
33-
loader: () => this.cloneFromRemote(normalizedLocator, nextOpts),
32+
loader: () => this.cloneFromRemote(locator, nextOpts),
3433
...opts.cacheOptions,
3534
});
3635

packages/plugin-git/sources/gitUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export async function resolveUrl(url: string, configuration: Configuration) {
266266
}
267267
};
268268

269-
return `${repo}#${resolve(protocol, request)}`;
269+
return normalizeRepoUrl(`${repo}#${resolve(protocol, request)}`);
270270
}
271271

272272
export async function clone(url: string, configuration: Configuration) {

0 commit comments

Comments
 (0)