I've been on the lookout for automation options to streamline the process of refactoring an Angular application, as doing it manually can be quite tedious.
We're working on reducing our app's shared module by extracting components/directives into their own modules through treeshaking. This requires going through each feature module in the app and verifying if a directive or component selector is present in the template. If found, the module containing the template must import the new module of the treeshaken directive/component from the shared module. Are there any tools available to assist with this refactoring task? It seems like a common requirement.
If there isn't a universal solution, I would still like to programmatically generate a list of absolute paths of components in the declarations array of any given .module.ts file.
The challenges I am currently encountering include:
- File names of components may differ from their Class names
- Some components are deeply nested within multiple barrel references
- TsConfig paths are customizing imports in the project