这是indexloc提供的服务,不要输入任何密码
Skip to content

chore: suggest ways to break cyclic dependencies #9799

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
merged 11 commits into from
Jan 28, 2025

Conversation

chris-olszewski
Copy link
Member

Description

Closes #9270 by providing a suggestion on how to break a cycle found in the package graph.

This implementation will only show the smallest cuts that could be made to break a cycle. So if the cycle can be broken by cutting only 2 dependencies than no cuts requiring 3 dependencies will be displayed.

This also removes an error stutter we had when hitting cycles. Previously we would display two copies of the underlying error.
Before:

[1 olszewski@chriss-mbp] /tmp/cycle $ turbo build                            
turbo 2.3.5-canary.0

  × Invalid package dependency graph: Cyclic dependency detected:
  │    @repo/ui, web, @repo/eslint-config
  ╰─▶ Cyclic dependency detected:
         @repo/ui, web, @repo/eslint-config

After:

[1 olszewski@chriss-mbp] /tmp/cycle $ turbo_dev --skip-infer build
turbo 2.3.4-canary.9

  × Invalid package dependency graph:
  ╰─▶ Cyclic dependency detected:
         @repo/eslint-config, @repo/ui, web
      The cycle can be broken by removing any of these sets of dependencies:
         {@repo/eslint-config -> web}

Testing Instructions

Unit tests for the cut sets as well as a snapshot test that displays the additional suggestion now on the error message.

Copy link

vercel bot commented Jan 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 1:26pm

@chris-olszewski chris-olszewski marked this pull request as ready for review January 24, 2025 19:40
@chris-olszewski chris-olszewski requested a review from a team as a code owner January 24, 2025 19:40
Copy link
Contributor

@anthonyshew anthonyshew left a comment

Choose a reason for hiding this comment

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

Aesthetic requests:

  • If you can remove the curlies from {@repo/eslint-config -> web} or put a space between them and the text, that'd be neat.
  • If you can put a new line before the The cycle can be broken by removing any of these sets of dependencies:, that'd also be neat.

Copy link
Contributor

@anthonyshew anthonyshew left a comment

Choose a reason for hiding this comment

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

Such a good DX improvement!

@chris-olszewski chris-olszewski force-pushed the olszewski/feat_view_cycle branch from 8438985 to a2da65a Compare January 28, 2025 13:26
@chris-olszewski chris-olszewski enabled auto-merge (squash) January 28, 2025 13:32
@chris-olszewski chris-olszewski merged commit 59a5e9c into main Jan 28, 2025
39 checks passed
@chris-olszewski chris-olszewski deleted the olszewski/feat_view_cycle branch January 28, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error messages from cyclical references
2 participants