ngx-usage
cli tool for analyzing usage of Angular components, pipes, directives, services
What it can do for me?
How does it work?
Using ts-morph
files from project
(provided by tsconfig file) are parsed and usage stats are counted.
Component usages are checked in templates of other components from project and component's class reference in other files from project.
Component is considered unused when it's selector is not used and class is only referenced in imports and Angular modules (declarations
,exports
,entryComponents
);
Usages in test files are skipped.
Test files are identified by name, default regular expression for test file is /\.spec\.ts$/
.
Usage
Install ngx-usage
globally or use it via npx
.
Usage: ngx-usage [options] [command]
Options:
-p, --project <path> tsconfig file path (required)
-V, --version output the version number
-h, --help display help for command
Commands:
components-unused List components that are probably not used - referenced only in module (*.module.ts) and test (*.spec.ts) files
components-summary [options] List usage stats of all components defined in project
help [command] display help for command