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

Workspace graph not computed correctly #948

Closed
6 tasks done
TimPetricola opened this issue Feb 18, 2025 · 4 comments
Closed
6 tasks done

Workspace graph not computed correctly #948

TimPetricola opened this issue Feb 18, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@TimPetricola
Copy link

Prerequisites

Reproduction url

https://stackblitz.com/edit/github-qsxgp9wd?file=debug.txt

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

When running knip for a single workspace, it's supposed to analyze both ancestors and dependents of the workspace. However it seems to currently only handle ancestors properly.

To reproduce:

  1. open the default monorepo reproduction StackBlitz (or here)
  2. run yarn knip -W packages/client --debug > debug.txt
  3. search for "Included workspaces" in debug.txt

I would expect to find:

  • @knip/templates-monorepo (the ancestor) ✅
  • @monorepo/client (the actual package) ✅
  • @monorepo/shared (the dependent) ❌

But the last one is missing.

As a result, analyzing a single package is broken as it reports false negatives used in dependents.

I'm not completely sure, but I think the bug comes form this line as:

  • wsPackages contains the package paths
  • but name contains the package name

So this is always evaluates to false

@TimPetricola TimPetricola added the bug Something isn't working label Feb 18, 2025
@webpro webpro closed this as completed in 63929e2 Feb 19, 2025
@webpro
Copy link
Member

webpro commented Feb 19, 2025

🚀 This issue has been resolved in v5.44.3. See Release 5.44.3 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

@webpro
Copy link
Member

webpro commented Feb 19, 2025

Thanks for the report, Tim! Turns out that line you point out was returning itself 😱 No idea how this could creep in there, but I've added some coverage so this shouldn't happen again.

@TimPetricola
Copy link
Author

@webpro wooh thanks for being so reactive! I confirm the fix works fine in latest version 🙏

@webpro
Copy link
Member

webpro commented Feb 19, 2025

🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants