Performance: Declarations, imports, and exports
MEDIUM IMPACT
This concept affects the initial bundle size and module loading time, impacting how fast the Angular app starts and renders.
import { CommonModule } from '@angular/common'; @NgModule({ declarations: [ComponentA], imports: [CommonModule], exports: [ComponentA] }) export class ComponentAModule {}
import { CommonModule } from '@angular/common'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { RouterModule } from '@angular/router'; @NgModule({ declarations: [ComponentA, ComponentB, ComponentC], imports: [CommonModule, FormsModule, ReactiveFormsModule, HttpClientModule, RouterModule], exports: [ComponentA, ComponentB, ComponentC] }) export class SharedModule {}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large shared module with many imports/exports | N/A | N/A | High due to delayed script execution | [X] Bad |
| Small focused module with minimal imports/exports | N/A | N/A | Low, scripts load and execute faster | [OK] Good |