Files
adastra_app/docs/decisions/0002-standalone-components-no-ngmodules.md
T

1.2 KiB

ADR 0002: Standalone Components Without NgModules

Date: 2026-04-26 Status: Accepted

Context

Historically, Angular required all components, directives, and pipes to be declared inside NgModules, which acted as compilation units. Angular 14 introduced standalone components as an opt-in alternative. Angular 17+ made them the recommended default and they became the foundation of the new @angular/build:application builder.

Decision

The entire application uses standalone components with no NgModules. The app entry point is app.config.ts (providers) + app.routes.ts (routing), with no AppModule.

Consequences

  • Positive: Each component explicitly declares its own imports, making dependencies visible and reducing hidden coupling.
  • Positive: Better tree-shaking — unused imports in one component don't affect others.
  • Positive: Aligns with Angular's long-term direction; compatible with the esbuild-based application builder.
  • Negative: Slightly more verbose component decorators (each must list its own imports).
  • Note: CommonModule should not be imported wholesale; use specific primitives (NgClass, DatePipe, etc.) or the newer @if/@for control flow syntax instead.