-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Flag to analyse all workspaces that depend on the one passed into -W
, for better entrypoint analysis
#249
Comments
Released a fix under the
I consider it basically a bugfix to the What Knip did before, was analyzing the provided With this fix, it includes the provided Needs some more testing on my end too, would be great if you could try it out :) |
Just published another After going back and forth in what I think we need, and how it could be implemented, this should version come a lot closer to what you requested initially. Its definitely still WIP, but it now only considers direct dependents and filters out results from other workspaces. Also added a little convenience to directly see what workspaces are included when using One issue that must still be fixed is that it filters out issues coming from the root workspace when using To be continued. Feel free to share any feedback or insights you might have :) |
After a few more tests and tweaks this landed in v2.32.3. With that, I'm going to close this ticket, but feel free to discuss further/report bugs. |
Not sure the best way to do this one, but basically the idea is to be able to detect what entrypoints of an internal workspace aren't used without running Knip across the entire monorepo.
Thought is the single workspace would be provided via flag, and only that workspace would have items reported, but any other workspace that depends on the passed workspace would also be included in analysis. A possible flag name could be
--traverse-upwards
,--resolve-dependents
,--resolve-upwards
, etc. Only directly listed dependencies (across all dev deps, prod deps, peer deps, etc) should be included, not transitive dependencies.In the following setup,
A: depends on B and C
B
C
If I ran
knip -W C --include-entry-exports --traverse-upwards
, I would expect Knip to provide me a report of what is unused within workspaceC
, however I would expect its analysis to also take into account usages withinA
but notB
. The current behaviour is that anything not internally used is reported as unused, even if it's used by other workspaces within the monorepo.This would make it significantly more feasible to use Knip to find unused entry exports of a shared internal library, without running it across an entire monorepo.
The big caveat here is that it does depend on dependencies being setup correctly, as it would miss workspaces that forget to include the dependency. I feel this isn't too big a deal, as Knip already provides functionality to resolve these cases anyway, and it's significantly better than the current situation of no other workspaces being included.
The text was updated successfully, but these errors were encountered: