Skip to content

[rush-lib] prevent workspace dependencies in decoupledLocalDependencies #4853

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

Merged

Conversation

jamesmaher-dd
Copy link
Contributor

Summary

Adds a check in install step to prevent a host project depending on a workspace: package version if the package is also listed in decoupledLocalDependencies.

Currently unaware of any use case that this would be intended. We came across this issue when migrating a dependency from an external feed (e.g. "@<namespace>/packageA": "1.2.3") to a workspace dependency, and didn't remove the package from decoupledLocalDependencies.

Details

We came across an issue which allows a host package to depend on a package with workspace: notation while also listing that package in its decoupledLocalDependencies. Because this is currently not checked, this can result in a missing dependency in CI runs because the package@workspace: is not guaranteed to be built prior to the package that depends on it, so here we're adding a check for it.

Replication steps

This is a very quick example to demonstrate how this situation occurs:

# hostProject1 package.json
"dependencies": {
  "@<namespace>/packageA": "workspace:*",
}
# rush.json
"projects": [
  {
    "packageName": "@<namespace>/hostProject1",
    "projectFolder": "apps/hostProject1",
    "decoupledLocalDependencies": ["@<namespace>/packageA"],
  },

How it was tested

Tested with local rush against our repo by replicating with the steps above and running rush update or rush install, and no warning logged or error being thrown.

Adding this changeset against our repo with the same replication results in the error added in this PR being thrown, preventing the erroneous state.

Copy link
Contributor

@aramissennyeydd aramissennyeydd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jamesmaher-dd

This comment was marked as duplicate.

@jamesmaher-dd
Copy link
Contributor Author

@microsoft-github-policy-service agree company="doordash"

@jamesmaher-dd jamesmaher-dd marked this pull request as ready for review July 30, 2024 17:49
jamesmaher-dd and others added 3 commits August 5, 2024 23:59
…ace-deps_2024-07-30-15-46.json

Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
…nager.ts

Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
@jamesmaher-dd jamesmaher-dd force-pushed the jmaher/prevent-decoupled-workspace-deps branch from c13ead6 to f45ffff Compare August 7, 2024 14:30
@jamesmaher-dd jamesmaher-dd requested a review from iclanton August 7, 2024 14:34
@jamesmaher-dd
Copy link
Contributor Author

hey @iclanton 👋🏻, how do we feel about merging this?

@iclanton iclanton merged commit f4a218d into microsoft:main Aug 19, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

4 participants