It is a cli tool to figure out the usage of any specific import
in your source files
- Supports glob patterns for searching in files.
- Supports scoping the import search. See
--scope
argument - Supports ignoring directories while searching
- Supports 3 output report formats -
table(default), csv, json
yarn add import-usage
or
npm install import-usage
import-usage -h
Options:
--filepath File or directory path or glob pattern [string] [required]
--components Comma separated component names [string] [required]
--ignore Directories to ignore i.e node_modules
[string] [default: "**/node_modules/**"]
--reportformat stdout format of data
[string] [choices: "table", "csv", "json"] [default: "table"]
--scope If defined, components only from this package will be searched
[string]
yarn add import-usage
or
npm install import-usage
In your package.json
{
"scripts" : {
"show-component-usage" : "import-usage --filepath='src/**/*.js' --components='Button,Input' --ignore='**/node_modules/**' --reportformat='csv' --scope='@scoped-package/ui'
}
}
yarn global add import-usage
or
npm -g install import-usage
then from terminal
import-usage --filepath='src/**/*.js' --components='Button,Input' --ignore='**/node_modules/**' --reportformat='csv' --scope='@scoped-package/ui'