When running lerna version
or lerna publish
it bumps versions of all the packages in yarn workspace and do update relevant devDependencies
but keeps unchanged versions in peerDependencies
so packages reference old & incorrect versions and that breaks functionality.
Example:
Packages A
, B
& C
where B
& C
depend on A
. All have version 0.0.1
.
According to recommendations for yarn workspaces dependencies are pointing to exact version, like:
"peerDependencies": {
"A": "0.0.1"
},
"devDependencies": {
"A": "0.0.1"
},
Change A
, modify B
to reflect change in A
.
Now if we run lerna publish
we'll get all 3 packages with version 0.0.2
but B
& C
keep referencing A@0.0.1
. This breaks functionality of B
as modification in B
depends on change in A
which exists only in 0.0.2
. So package.json
of B
starts to look like:
"peerDependencies": {
"A": "0.0.1"
},
"devDependencies": {
"A": "0.0.2"
},
while we would like it to look like:
"peerDependencies": {
"A": "0.0.2"
},
"devDependencies": {
"A": "0.0.2"
},
When there is a lot of packages depending on A, or of there is an hierarchy of dependencies (e.g. C
=> [A
, {B
=> A
})] it's hard to impossible to update all of the dependencies manually.
Probably it's by design: (but we need a way to solve this)
So it seems Lerna is capable to analyse dependencies tree and update devDependencies
but does not do that for peerDependencies
intentionally.
But I'm struggling to find what is a recommended & right appoach here when we do need to update peerDependencies
as well.
So, how do we tackle this?
For reference:
- Repository in question: https://github.com/angular-dnd/angular-dnd
- Issue: https://github.com/angular-dnd/angular-dnd/issues/4