|
| 1 | +### export-tools |
| 2 | + |
| 3 | +`export-tools` is an unpublished package used to house tools related to managing the imports and exports of our frontend |
| 4 | +packages. |
| 5 | + |
| 6 | +# Setup |
| 7 | +To install the dependencies used by `export-tools` run `npm install`. |
| 8 | + |
| 9 | +# Tools |
| 10 | +## findUnused |
| 11 | +The purpose of `findUnused` is to document everything exported by our packages, as well as everything our modules import |
| 12 | +from those packages, with the ultimate goal of determining what exports are unused. |
| 13 | + |
| 14 | +### setup |
| 15 | +By default, `findUnused` does not search in EHR modules, as not everyone will have those in their enlistment. To include |
| 16 | +EHR modules in your search you need to set the `EHR_MODULE_DIRS` environment variable. If you have the EHR modules in |
| 17 | +your enlistment you should set `EHR_MODULE_DIRS` to `$LABKEY_HOME/server/modules`. If you don't have EHR modules in |
| 18 | +your enlistment you can clone them to any alternate directory path and set the `EHR_MODULE_DIRS` to that path. |
| 19 | + |
| 20 | +### usage |
| 21 | +To run the tool run `npm run findUnused`. This will parse the `index.ts` file for the `ui-components`, and `ui-premium` |
| 22 | +packages to find what they export. It will then search all the known module directories that use `ui-components` or |
| 23 | +`ui-premium` for usages of the packages. After the search is complete `findUsages` will write 6 files to the working |
| 24 | +directory: |
| 25 | + |
| 26 | +- `components-exports.txt` - The list of all items exported in the `ui-components` `index.ts` |
| 27 | +- `components-imports.txt` - The list of all items imported from `ui-components` by modules |
| 28 | +- `components-unused.txt` - The list of all exports that are not imported by any modules |
| 29 | +- `premium-exports.txt` - The list of all items exported in the `ui-premium` `index.ts` |
| 30 | +- `premium-imports.txt` - The list of all items imported from `ui-premium` by modules |
| 31 | +- `premium-unused.txt` - The list of all exports that are not imported by any modules |
| 32 | + |
| 33 | +## Future tools |
| 34 | +The dependency we used to implemement `findUnused`, `ts-morph`, is an AST toolkit for TypeScript. In the future we could |
| 35 | +leverage `ts-morph` to write tools to accomplish the following: |
| 36 | + |
| 37 | +- Sorting our exports |
| 38 | +- Automatically remove unused exports |
| 39 | +- Rename an export or import (useful if we want to do something like rename a method from `foo` to `fooDeprecated`) |
0 commit comments