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
Originally posted by ma-multipla April 25, 2023
I'm having trouble comprehending the purpose of a specific code fragment. In the context of utilizing the workspace protocol for peer dependencies (e.g. "workspace:^"). Yarn Berry's default behavior is to substitute them with the locally resolved version upon generating the tarball through yarn pack. However, with the current Lerna version, the workspace protocol remains unaltered when applied to peer dependencies, resulting in incompatibility with package managers that don't support the protocol, such as npm.
Using the --allow-peer-dependencies-update flag only bumps the version in specific cases and in my case it only removed the "workspace:" portion, leaving the "^". I've read the documentation about the flag, but I have difficulties seeing the benefits of the current approach.
My questions is as follows:
Why isn't the --allow-peer-dependencies-update flag enabled by default for the workspace protocol and why is it only bumping the workspace protocol when the version is specified like this "workspace:^1.2.0". This essentially makes it not possible to only use the npm range operator without specifying the version, e.g. "workspace:^". Why would you want this?
The documentation is also a bit misleading:
{
"name": "B",
"dependencies": {
"A": "workspace:^1.2.0"// will update to "workspace:^1.3.0","B": "^0.4.0": // will update to "^0.5.0"
},
"peerDependencies": {
"A": "workspace:^1.2.0"// will update to "workspace:^1.3.0""B": ">=0.2.0": // will not be updateed because range with operator (>=) are skipped
}
}
It will update to "^1.3.0" not "workspace:^1.3.0". My expectation would be that either "workspace:^" as well as "workspace:^1.2.0" should lead to a version bump to "^1.3.0" considering the example above.
Here's the code snippet in question:
// Perform certain actions when there are peer dependenciesif(this.peerDependencies?.[depName]){// If the user allows peer bump and it's a regular semver version, add it to the array of dependencies to potentially bump// However, don't do this when the semver has a range with an operator, e.g., bump ("^2.0.0") but not (">=2.0.0" or "workspace:<2.0.0" or "workspace:*")// prettier-ignoreif(allowPeerDependenciesUpdate&&/^(workspace:)?[~^]?[\d\.]+([\-]+[\w\.\-\+]+)*$/i.test(this.peerDependencies[depName]||'')){updatingDependencies.push(this.peerDependencies);}// When peer bump is disabled, some peerDependencies might not be reviewed and could still have the `workspace:` prefix, so ensure to remove any of these prefixeselseif(updatedByCommand==='publish'&&this.peerDependencies[depName].startsWith('workspace:')){this.peerDependencies[depName]=this.peerDependencies[depName].replace('workspace:','');}}
ghiscoding
changed the title
Handling Workspace Protocol in Peer Dependencies with Lerna
Workspace Protocol with "workspace:^" in Peer Dependencies doesn't work
Apr 27, 2023
Discussed in #587
Originally posted by ma-multipla April 25, 2023
I'm having trouble comprehending the purpose of a specific code fragment. In the context of utilizing the workspace protocol for peer dependencies (e.g.
"workspace:^"
). Yarn Berry's default behavior is to substitute them with the locally resolved version upon generating the tarball throughyarn pack
. However, with the current Lerna version, the workspace protocol remains unaltered when applied to peer dependencies, resulting in incompatibility with package managers that don't support the protocol, such as npm.Using the
--allow-peer-dependencies-update
flag only bumps the version in specific cases and in my case it only removed the "workspace:" portion, leaving the "^". I've read the documentation about the flag, but I have difficulties seeing the benefits of the current approach.My questions is as follows:
Why isn't the
--allow-peer-dependencies-update
flag enabled by default for the workspace protocol and why is it only bumping the workspace protocol when the version is specified like this"workspace:^1.2.0"
. This essentially makes it not possible to only use the npm range operator without specifying the version, e.g."workspace:^"
. Why would you want this?The documentation is also a bit misleading:
https://github.com/lerna-lite/lerna-lite/blob/main/packages/version/README.md#with-flag-enabled
It will update to "^1.3.0" not "workspace:^1.3.0". My expectation would be that either
"workspace:^"
as well as"workspace:^1.2.0"
should lead to a version bump to"^1.3.0"
considering the example above.Here's the code snippet in question:
Source: Lerna Lite Core Package.ts
The text was updated successfully, but these errors were encountered: