| 1 |
A dependency that will first install its deps in one place, then have to |
| 2 |
have them duped to accommodate a peer dependency from another of its deps. |
| 3 |
|
| 4 |
This models the behavior of [email protected] |
| 5 |
|
| 6 |
``` |
| 7 |
gatsby -> ([email protected], @pmmmwh/[email protected]) |
| 8 |
@pmmmwh/[email protected] -> PEER [email protected] |
| 9 |
``` |
| 10 |
|
| 11 |
Initially `@pmmmwh/[email protected]` is installed |
| 12 |
alongside `gatsby` and `[email protected]` like so: |
| 13 |
|
| 14 |
``` |
| 15 |
+-- root |
| 16 |
+-- gatsby |
| 17 |
+-- @pmmmwh/react-refresh-webpack-plugin |
| 18 |
+-- [email protected] |
| 19 |
``` |
| 20 |
|
| 21 |
Then, the peerDep from `@pmmmwh/react-refresh-webpack-plugin` on |
| 22 |
`[email protected]` is evaluated, and has nowhere to go except where the |
| 23 |
`[email protected]` is already living. |
| 24 |
|
| 25 |
Since we _can_ move `[email protected]` underneath `gatsby`, we do so. |
| 26 |
|
| 27 |
In this case: |
| 28 |
|
| 29 |
``` |
| 30 |
override -> (a@2, v@1) |
| 31 |
v@1 -> PEER(a@1) |
| 32 |
``` |
| 33 |
|
| 34 |
This fails to install by default, because the `a` dep collides. |
| 35 |
|
| 36 |
With `--force`, we override the peer with the direct root dep, and get: |
| 37 |
|
| 38 |
``` |
| 39 |
override |
| 40 |
+-- v@1 |
| 41 |
+-- a@2 (valid for root, invalid for v) |
| 42 |
+-- b@2, c@2, ... |
| 43 |
``` |
| 44 |
|
| 45 |
When installing `override` as a dep, we get: |
| 46 |
|
| 47 |
``` |
| 48 |
push-dep |
| 49 |
+-- v@1 |
| 50 |
+-- a@1 |
| 51 |
+-- b@1, c@1, ... |
| 52 |
+-- override |
| 53 |
+-- a@2 |
| 54 |
+-- b@2, c@2, ... |
| 55 |
``` |
| 56 |
|
| 57 |
which is a compliant dependency resolution, where every module gets the |
| 58 |
version of their dep that they declare. |