From b7ae11cf821212ac716672d00a4ccbe5a9f59190 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 3 Mar 2023 14:45:35 +0200 Subject: [PATCH] docs: add explanation about conflicting peer dependencies ref #6153 --- pnpm/CHANGELOG.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pnpm/CHANGELOG.md b/pnpm/CHANGELOG.md index 3a222f5656..f4dba565f4 100644 --- a/pnpm/CHANGELOG.md +++ b/pnpm/CHANGELOG.md @@ -24,7 +24,7 @@ esbuild ``` - This makes sense because `webpack` is used in two projects, and one of the projects doesn't have `esbuild`, so the two projects cannot share the same instance of `webpack`. However, this is not what most developers expect, especially since in a hoisted `node_modules`, there would only be one instance of `webpack`. Therefore, you may now use the `dedupe-peer-dependents` setting to deduplicate `webpack` when it has no conflicting peer dependencies. In this case, if we set `dedupe-peer-dependents` to `true`, both projects will use the same `webpack` instance, which is the one that has `esbuild` resolved: + This makes sense because `webpack` is used in two projects, and one of the projects doesn't have `esbuild`, so the two projects cannot share the same instance of `webpack`. However, this is not what most developers expect, especially since in a hoisted `node_modules`, there would only be one instance of `webpack`. Therefore, you may now use the `dedupe-peer-dependents` setting to deduplicate `webpack` when it has no conflicting peer dependencies (explanation at the end). In this case, if we set `dedupe-peer-dependents` to `true`, both projects will use the same `webpack` instance, which is the one that has `esbuild` resolved: ``` node_modules @@ -39,6 +39,26 @@ esbuild ``` + **What are conflicting peer dependencies?** By conflicting peer dependencies we mean a scenario like the following one: + + ``` + node_modules + .pnpm + webpack@1.0.0_react@16.0.0_esbuild@1.0.0 + webpack@1.0.0_react@17.0.0 + project1 + node_modules + webpack -> ../../node_modules/.pnpm/webpack@1.0.0/node_modules/webpack + react (v17) + project2 + node_modules + webpack -> ../../node_modules/.pnpm/webpack@1.0.0_esbuild@1.0.0/node_modules/webpack + esbuild + react (v16) + ``` + + In this case, we cannot dedupe `webpack` as `webpack` has `react` in its peer dependencies and `react` is resolved from two different versions in the context of the two projects. + ### Patch Changes - The configuration added by `pnpm setup` should check if the pnpm home directory is already in the PATH before adding to the PATH.