Skip to content

Commit f9767fd

Browse files
Gudahttgantunesr
authored andcommitted
Add peer dependencies between packages (#1003)
Packages now list `peerDependencies` to represent the expectation that a specific package version is setup with the controller messenger. This ensures that projects using these packages get a warning upon install if they are using incompatible package versions. This lets us safely make breaking changes to controller messenger events and actions. The constraints needed adjustment to allow the same dependency to be declared both in `dependencies` and `peerDependencies`. The constraint now ensures packages aren't listed both in `dependencies` and `devDependencies` instead. - FIXED: - The following packages now warn if a required package is not present: - `assets-controllers` - `gas-fee-controller` - `permission-controller` **Checklist** - [x] Tests are included if applicable - [x] Any added code is fully documented
1 parent d7897f9 commit f9767fd

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

constraints.pro

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,13 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, OtherDependencyRange, Dep
224224
npm_version_range_out_of_sync(DependencyRange, OtherDependencyRange).
225225

226226
% If a dependency is listed under "dependencies", it should not be listed under
227-
% any other "*dependencies" lists. We match on the same dependency range so that
228-
% if a dependency is listed twice in the same manifest, their versions are
229-
% synchronized and then this constraint will apply and remove the "right"
230-
% duplicate.
227+
% "devDependencies". We match on the same dependency range so that if a
228+
% dependency is listed under both lists, their versions are synchronized and
229+
% then this constraint will apply and remove the "right" duplicate.
231230
gen_enforced_dependency(WorkspaceCwd, DependencyIdent, null, DependencyType) :-
232231
workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, 'dependencies'),
233232
workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType),
234-
DependencyType \= 'dependencies'.
233+
DependencyType == 'devDependencies'.
235234

236235
% eth-query has an unlisted dependency on babel-runtime, so that package needs
237236
% to be present if eth-query is present.

packages/assets-controllers/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
"typedoc-plugin-missing-exports": "^0.22.6",
6666
"typescript": "~4.6.3"
6767
},
68+
"peerDependencies": {
69+
"@metamask/network-controller": "workspace:^"
70+
},
6871
"engines": {
6972
"node": ">=14.0.0"
7073
},

packages/gas-fee-controller/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
"typedoc-plugin-missing-exports": "^0.22.6",
5555
"typescript": "~4.6.3"
5656
},
57+
"peerDependencies": {
58+
"@metamask/network-controller": "workspace:^"
59+
},
5760
"engines": {
5861
"node": ">=14.0.0"
5962
},

packages/permission-controller/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
"typedoc-plugin-missing-exports": "^0.22.6",
5151
"typescript": "~4.6.3"
5252
},
53+
"peerDependencies": {
54+
"@metamask/approval-controller": "workspace:^"
55+
},
5356
"engines": {
5457
"node": ">=14.0.0"
5558
},

yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,8 @@ __metadata:
14341434
typedoc-plugin-missing-exports: ^0.22.6
14351435
typescript: ~4.6.3
14361436
uuid: ^8.3.2
1437+
peerDependencies:
1438+
"@metamask/network-controller": "workspace:^"
14371439
languageName: unknown
14381440
linkType: soft
14391441

@@ -1707,6 +1709,8 @@ __metadata:
17071709
typedoc-plugin-missing-exports: ^0.22.6
17081710
typescript: ~4.6.3
17091711
uuid: ^8.3.2
1712+
peerDependencies:
1713+
"@metamask/network-controller": "workspace:^"
17101714
languageName: unknown
17111715
linkType: soft
17121716

@@ -1844,6 +1848,8 @@ __metadata:
18441848
typedoc: ^0.22.15
18451849
typedoc-plugin-missing-exports: ^0.22.6
18461850
typescript: ~4.6.3
1851+
peerDependencies:
1852+
"@metamask/approval-controller": "workspace:^"
18471853
languageName: unknown
18481854
linkType: soft
18491855

0 commit comments

Comments
 (0)