Removing unused Angular module dependencies (import and providers)

Say I have a module SharedComponents. This module has a component SomeView. This component used the directive SomeDirectivefrom DirectivesModule. I have something like this:

@NgModule({
  imports: [DirectivesModule, ...],
  declarations: [SomeView, ...],
  ...
})

Then I need to move SomeViewto another module. This leaves me:

@NgModule({
  imports: [DirectivesModule, ...],
  declarations: [...],
  ...
})

No other declared element uses DirectivesModule. This is no longer needed, so I would like to remove it. But I can’t say that it’s safe to delete without studying all the other ads.

So my question is: is there a way to find if the given module can be imported or the provider can be deleted safely? In a project I'm working on, where one module can load twenty others, a clean task is a very difficult task.

+4

Source: https://habr.com/ru/post/1693871/


All Articles