vue-unused-components-checker
vue-unused-components-checker copied to clipboard
[IDEA] Use dependency graph for finding unused components
The current implementation uses a regex to find the import commands and thus detects components that have not been imported anywhere.
However if we have component A that imports Component B, but also Component A is not imported anywhere, we would not be able to find that component B is thus also not used anywhere.
Note: we would find that component A is unused and after its removal on a second run of the checker, we would then be able to detect B
It would be nicer if we directly were able to find the whole structure of unused components directly.
This could be solved by building a graph with the components as nodes and the edges represent the imports. every subgraph that is not then imported anywhere (isolated subgraph) could then be flagged by the checker.
Possibly further benefits of this approach:
- Less memory intensive
- Better feedback for the user (whole graph, maybe even a visualization)