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
[Feature] Aliases workspace:^ and workspace:~ #2658
This feature is important to have in this repository; a contrib plugin wouldn't do
Describe the user story
I would like that versions of workspace package dependencies to refer to the latest available version, and at the same time make them compatible with future security patches or minor improvements.
Right now there is workspace:* which updates the version of a workspace dependency automatically on release. This is good because the package.json#dependencies always point to versions known to work with the package and tested (if tests are run before release).
But it's excessively specific. workspace: * is substituted with an exact version like "dep": "1.0.0", which is incompatible with future security patches or minor improvements of the dependency.
Describe the solution you'd like
I would like to specify "dep": "workspace:~" and to be substituted on release with the current version of "dep" but allowing security patches, e.g. "dep": "workspace:~1.0.0". Also I think it would be useful to specify "dep": "workspace:^" and get "dep": "workspace:^1.0.0".
Describe the drawbacks of your solution
More complexity and there is a risk of creating technical debt
Describe alternatives you've considered
Specifying full workspace versions workspace:~0.9.0 and running a script before release to bump the version number, but it's kind of ugly.
If the workspace has dependencies a:1.0.0, b:2.0.0c:3.0.0 with a,b,c being npm packages, the following declarations should be the result of this enhancement
@certainlynotprithvi that is right, those substitutions have to be made when the project is packed.
For internal dependency resolution, the behavior of workspace:^ and workspace:~ is the same as workspace:*. That is, they point to a project in the workspace that matches the name of the package.
thrownewReportError(MessageName.WORKSPACE_NOT_FOUND,`${structUtils.prettyDescriptor(project.configuration,descriptor)}: No local workspace found for this range`);
}
}else{
letversionToWrite: string;
// For workspace:path/to/workspace and workspace:* we look up the workspace version
Activity
arcanis commentedon Mar 30, 2021
Yep, I'd be open to have support for
workspace:~andworkspace:^👍certainlynotprithvi commentedon Apr 22, 2021
Hi @arcanis @javier-garcia-meteologica I would like a try at this issue
So just to write out my understanding
If the workspace has dependencies
a:1.0.0,b:2.0.0c:3.0.0witha,b,cbeing npm packages, the following declarations should be the result of this enhancementa: workspace:*=>a: 1.0.0b: workspace:^=>b: ^2.0.0c: workspace:~=>c: ~3.0.0javier-garcia-meteologica commentedon Apr 22, 2021
@certainlynotprithvi that is right, those substitutions have to be made when the project is packed.
For internal dependency resolution, the behavior of
workspace:^andworkspace:~is the same asworkspace:*. That is, they point to a project in the workspace that matches the name of the package.arcanis commentedon Apr 22, 2021
Indeed 👍
For the pack translation logic, the relevant source code is here:
berry/packages/plugin-pack/sources/index.ts
Lines 43 to 68 in a546d72
For the workspace selection, the relevant line is here:
berry/packages/yarnpkg-core/sources/Workspace.ts
Line 101 in a546d72
Note that we'll also need tests, which would be implemented here:
https://github.com/yarnpkg/berry/blob/a546d725d9f3f9b9881a9d973b48c241935d1910/packages/acceptance-tests/pkg-tests-specs/sources/protocols/workspace.test.ts
feat: add support for workspace:^ and workspace:~
feat: add support for `workspace:~` and `workspace:^` aliases (#3250)