You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: accepted/0000-optional-peer-dependencies.md
+7-11Lines changed: 7 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -15,19 +15,15 @@ While it currently already works, it causes semantical issues: are peer dependen
15
15
16
16
## 2. Detailed Design
17
17
18
-
Yarn will introduce a new protocol, `optional:`. If a peer dependency cannot be found but the requested range begins with `optional:` then Yarn will silence any warning and assume that the package will check at runtime whether it should use it or not.
19
-
20
-
**Important:** The `optional:` protocol will not be valid in anything else than peer dependencies. We reserve the right later to potentially implement it for other fields, but for the time being we're only interested in the `peerDependencies` use case.
18
+
Yarn will introduce a new field, `peerDependenciesMeta`. This field will be a dictionary that will allow adding metadata to the peer dependencies. As a first step, we'll only add the `optional` metadata field.
21
19
22
20
## 3. How We Teach This
23
21
24
-
- We can just call the optional protocol.
25
-
26
-
- Being stricly backward compatible, it doesn't require us to push changes onto our users, so the teaching should be simple and spread on the long time.
22
+
- Being stricly backward compatible it doesn't require us to push changes onto our users, so the teaching should be simple and spread on the long time.
27
23
28
24
## 4. Drawbacks
29
25
30
-
- It requires adoption from other package managers, otherwise there's a risk to fracture the ecosystem if they decide to go with (for example) naming the field `opt:`.
26
+
- It requires adoption from other package managers, otherwise there's a risk to fracture the ecosystem if they decide to go with (for example) naming the field `peerDependenciesSettings`.
31
27
32
28
## 5. Alternatives
33
29
@@ -41,12 +37,12 @@ Yarn will introduce a new protocol, `optional:`. If a peer dependency cannot be
41
37
42
38
- It would have a completely different meaning from the already existing `optionalDependencies` field.
43
39
40
+
- We could add an `optional:` protocol
41
+
42
+
- It's been noted it could potentially cause issues on older package managers.
43
+
44
44
- We could overhaul how the dependencies are defined, and fix them once and for all.
45
45
46
46
- This sounds a huge undertaking for a problem relatively minor at the moment.
47
47
48
48
- It seems unlikely we can reach a consensus in a reasonable timeframe.
49
-
50
-
## 6. Unresolved Questions
51
-
52
-
Will all the package managers work properly when seeing a `peerDependencies` range prefixed by `optional:`? Logic would say that yes, since peer dependency ranges are typically an hint rather than a strict enforcement (except maybe for npm 1 & 2), but it might trigger a bug in some versions of some package managers.
0 commit comments