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

[Feature]: Warn on circular dependencies within workspace #1753

Open
2 tasks
SimenB opened this issue Aug 24, 2020 · 1 comment
Open
2 tasks

[Feature]: Warn on circular dependencies within workspace #1753

SimenB opened this issue Aug 24, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@SimenB
Copy link

SimenB commented Aug 24, 2020

  • I'd be willing to implement this feature
  • This feature can already be implemented through a plugin

Describe the user story

While dependency cycles work, they should be avoided as they might cause race conditions between packages publishes and when the modules are loaded (if they both have side effects depending on the other).

Describe the solution you'd like

Yarn should warn in this case, similar to what lerna already does (see jestjs/jest#9712 for example output).

Describe the drawbacks of your solution

It's not always a problem. In Jest's specific case it's not, but it'd still be nice if yarn at least warned of this as I think it's a pattern that should be discouraged and Yarn is in a unique position to discover this.

Describe alternatives you've considered

I looked into https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-cycle.md but that's for "local" modules.

Additional context

N/A

@SimenB SimenB added the enhancement New feature or request label Aug 24, 2020
@akphi
Copy link

akphi commented Sep 23, 2021

If we want to do this check for the whole dependency graph (i.e. including packages outside of your own monorepo), I don't think I have a workaround for that now. But if we just need to scan for circular dependencies for workspaces within your monorepo, you can use something like:

yarn workspaces foreach --topological-dev exec "echo '' >/dev/null"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants