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
{{ message }}
Repository navigation
Packages published with peer dependencies still containing workspace protocol (pnpm + lerna) #3671
I use the workspace protocol for all packages defined within the repo.
I checked the content of one of the published package package.json, and found out that while dependencies (and devDependencies) versions are properly replaced:
I tried to run pnpm pack on one of the package to see how it was handling this, and it properly replaced the peerDependencies version: "@nivo/core": "0.82.0" while lerna didn't.
Expected Behavior
I would expect the peerDependencies to be replaced as well.
There's currently 2 issues in Lerna's code related to this
Lerna only ever does 1 dependency version replacement, as soon as a package name is found it will bump the version on that package but it will stop there (following this order: dependencies, then devDependencies, then optionalDependencies and then peerDependencies) and continue with the next package dependency in the list, in other words considering what is shown below, it will only replace the first one with the highest priority (in this case dependencies) and then since it already did the first occurrence of @nivo/core in dependencies, the action is considered as done on that dependency name and will continue to the next name and will never see/visit the next peer deps one with the same name
"dependencies": {"@nivo/core": "workspace:*"// this one will be found and replaced},"peerDependencies": {"@nivo/core": "workspace:*"// but this will be skipped because Lerna does not loop },
As @ghiscoding said in his second point, peer deps will not be updated by lerna version or publish when bumping the version of packages for reasons mentioned in that thread.
However, it does make sense for Lerna to still replace the workspace aliases in peerDeps with their appropriate version for consistency with npm/yarn/pnpm. After all, the workspace prefix should probably never appear in published package.json files.
Activity
plouc commentedon May 2, 2023
Probably related to #3637.
ghiscoding commentedon May 2, 2023
also related to #2402 and #955
There's currently 2 issues in Lerna's code related to this
dependencies, thendevDependencies, thenoptionalDependenciesand thenpeerDependencies) and continue with the next package dependency in the list, in other words considering what is shown below, it will only replace the first one with the highest priority (in this casedependencies) and then since it already did the first occurrence of@nivo/coreindependencies, the action is considered as done on that dependency name and will continue to the next name and will never see/visit the next peer deps one with the same namelerna publish#1018 and later confirmed by Lerna maintainer in the same issuefahslaj commentedon May 3, 2023
As @ghiscoding said in his second point, peer deps will not be updated by lerna version or publish when bumping the version of packages for reasons mentioned in that thread.
However, it does make sense for Lerna to still replace the workspace aliases in peerDeps with their appropriate version for consistency with npm/yarn/pnpm. After all, the workspace prefix should probably never appear in published package.json files.
plouc commentedon May 3, 2023
Yes, that was also my thinking, the workspace protocol doesn't really make sense once the packages are published and not in a workspace anymore.
JamesHenry commentedon Jul 14, 2026
Closing for housekeeping as this shipped a while ago in #4203