Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support other workspace: specifiers #26726

Closed
bartlomieju opened this issue Nov 4, 2024 · 2 comments · Fixed by #27096
Closed

Support other workspace: specifiers #26726

bartlomieju opened this issue Nov 4, 2024 · 2 comments · Fixed by #27096

Comments

@bartlomieju
Copy link
Member

Currently Deno supports workspace:* specifiers in package.json, but tools like pnpm also support
workspace:^, workspace:~ and others.

See https://pnpm.io/workspaces#publishing-workspace-packages

Necessary changes would need to be applied around this code:
https://github.com/search?q=org%3Adenoland+PackageJsonDepValue%3A%3AWorkspace&type=code

@bartlomieju
Copy link
Member Author

I did some digging into this and here's what I found:

  1. Handling of workspace: specifiers in package.json is done here: https://github.com/denoland/deno_package_json/blob/bf59efc107b0d7191018e0d06ef1341f86fe6c1b/src/lib.rs#L346
  2. The workspace: prefix is stripped and the remainder is passed to VersionReq::parse_from_npm from deno_semver: https://github.com/denoland/deno_semver/blob/6fba7fd973fc9cc77a54c1412d0e2a0fb357730f/src/npm.rs#L92
  3. * or x.y.z are valid ranges in this context, but ~ and ^ are not
  4. It appears that simply stripping workspace: is not good enough here and we should have a dedicated functionality in deno_semver to handle workspace: version constraints that will accept ~ and ^, otherwise we'd have to alter the current parsing which would break other stuff, because "mypackage": "^" is not a valid range, but "mypackage": "workspace:^" is.

@dsherret do you agree here?

@dsherret
Copy link
Member

It looks good, but I think we probably dont' need any changes in deno_semver. Probably it could just be handled in deno_package_json (I'm not sure though)

bartlomieju added a commit that referenced this issue Dec 5, 2024
)

This commit adds support for understanding "workpace:^"
and "workspace:~" version constraints in npm/pnpm workspaces.

This is done by upgrading various crates to their latest versions.

Closes #26726

---------

Co-authored-by: David Sherret <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants