Skip to content

Commit

Permalink
Add peer dependencies between packages
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gudahtt committed Dec 3, 2022
1 parent 4de13fe commit 88b9611
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
9 changes: 4 additions & 5 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,13 @@ gen_enforced_dependency(WorkspaceCwd, DependencyIdent, OtherDependencyRange, Dep
npm_version_range_out_of_sync(DependencyRange, OtherDependencyRange).

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

% eth-query has an unlisted dependency on babel-runtime, so that package needs
% to be present if eth-query is present.
Expand Down
3 changes: 3 additions & 0 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
"typedoc-plugin-missing-exports": "^0.22.6",
"typescript": "~4.6.3"
},
"peerDependencies": {
"@metamask/network-controller": "workspace:^"
},
"engines": {
"node": ">=14.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/gas-fee-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
"typedoc-plugin-missing-exports": "^0.22.6",
"typescript": "~4.6.3"
},
"peerDependencies": {
"@metamask/network-controller": "workspace:^"
},
"engines": {
"node": ">=14.0.0"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/permission-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"typedoc-plugin-missing-exports": "^0.22.6",
"typescript": "~4.6.3"
},
"peerDependencies": {
"@metamask/approval-controller": "workspace:^"
},
"engines": {
"node": ">=14.0.0"
},
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,8 @@ __metadata:
typedoc-plugin-missing-exports: ^0.22.6
typescript: ~4.6.3
uuid: ^8.3.2
peerDependencies:
"@metamask/network-controller": "workspace:^"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1707,6 +1709,8 @@ __metadata:
typedoc-plugin-missing-exports: ^0.22.6
typescript: ~4.6.3
uuid: ^8.3.2
peerDependencies:
"@metamask/network-controller": "workspace:^"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1844,6 +1848,8 @@ __metadata:
typedoc: ^0.22.15
typedoc-plugin-missing-exports: ^0.22.6
typescript: ~4.6.3
peerDependencies:
"@metamask/approval-controller": "workspace:^"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 88b9611

Please sign in to comment.