Skip to content

Commit 835c327

Browse files
authored
Update 0000-optional-peer-dependencies.md
1 parent 7f8f0a1 commit 835c327

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

accepted/0000-optional-peer-dependencies.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ While it currently already works, it causes semantical issues: are peer dependen
1515

1616
## 2. Detailed Design
1717

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.
2119

2220
## 3. How We Teach This
2321

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.
2723

2824
## 4. Drawbacks
2925

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`.
3127

3228
## 5. Alternatives
3329

@@ -41,12 +37,12 @@ Yarn will introduce a new protocol, `optional:`. If a peer dependency cannot be
4137

4238
- It would have a completely different meaning from the already existing `optionalDependencies` field.
4339

40+
- We could add an `optional:` protocol
41+
42+
- It's been noted it could potentially cause issues on older package managers.
43+
4444
- We could overhaul how the dependencies are defined, and fix them once and for all.
4545

4646
- This sounds a huge undertaking for a problem relatively minor at the moment.
4747

4848
- 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

Comments
 (0)