[EDIT]: My bad, I'm a bit tired and I've mixed two ideas in my mind resulting in a question which doesn't really mean much ... I'll blame it on the coffee! :P
This is more of a knowledge question rather than an actual problem, but...
I'm currently developing an angular web application and, as I started "messing" with tests I realized most of the tests fail because I didn't include the components in the component-name.ts
file while i import them in app.module.ts
, yet I call custom components.
(E.G.: <app-menu></app-menu>
Or <router-outlet></router-outlet>
)
Now, the solution is pretty easy: just import the modules and it's done, but it made me wonder... performance wise is it worth to import them?
How does Angularjs deals with re-importing the same thing multiple times?
For instance: let's say I
import { RouterModule } from '@angular/router';
in app.module.ts
and that then I
import { RouterModule } from '@angular/router';
in ./menu/menu.module.ts
Does angular removes the second import in compile phase or does it simply ignores it?
simply explained here:
https://medium.com/@cyrilletuzi/understanding-angular-modules-ngmodule-and-their-scopes-81e4ed6f7407
you should not import multiple times a module, but it's necessary when you have to make that module visible to every sub-components -- and this is NOT a RE-import --