Open-Source Wikis

/

Angular

/

Packages

/

@angular/core

angular/angular

@angular/core

The runtime. The compiled output of every Angular template ultimately calls instructions defined here. Everything else in the framework — components, directives, DI, change detection, hydration, signals — is implemented or rooted in this package.

Purpose

@angular/core provides:

  • The Ivy runtime: LView/TView, instructions, the renderer interface (Renderer2).
  • The decorator metadata that ngtsc recognizes (@Component, @Directive, @Pipe, @Injectable, @NgModule).
  • Hierarchical dependency injection: Injector, EnvironmentInjector, inject().
  • Change detection scheduling and the application reference (ApplicationRef).
  • The reactivity primitives (signal, computed, effect) and signal-based component APIs (input, output, model, viewChild).
  • Hydration of server-rendered DOM (provideClientHydration).
  • Lifecycle hooks, content/view queries, structural directive helpers.
  • The defer block runtime.
  • Testing helpers (TestBed).

Directory layout

packages/core/
├── src/
│   ├── application/        # ApplicationRef, lifecycle, scheduler
│   ├── change_detection/   # ChangeDetectorRef and zoneless scheduler
│   ├── di/                 # Injector tree (definition layer)
│   ├── render3/            # Ivy runtime (instructions, LView, hot path)
│   │   ├── instructions/   # ɵɵelementStart, ɵɵproperty, ...
│   │   ├── interfaces/     # TView, LView, TNode, RNode types
│   │   ├── reactivity/     # Signal/effect integration with views
│   │   ├── hydration/      # Hydration helpers in the runtime
│   │   └── debug/          # Devtools-facing debug functions
│   ├── hydration/          # Hydration coordination + annotations
│   ├── defer/              # @defer block triggers and scheduler
│   ├── i18n/               # Runtime i18n message extraction
│   ├── linker/             # Compatibility layer with the linker package
│   ├── reflection/         # Decorator metadata helpers
│   ├── sanitization/       # XSS sanitizers used by bindings
│   └── ...
├── primitives/             # Standalone reactivity primitives (signals)
│   └── signals/
├── rxjs-interop/           # toSignal / toObservable bridges
├── testing/                # TestBed and harness exports
├── schematics/             # ng update migrations and ng-add
└── public_api.ts           # The npm-exported surface

primitives/signals is intentionally a separate entry point so that other Angular packages (and external consumers) can depend on the reactivity layer without pulling in the whole runtime.

Key abstractions

Type / function File What it is
LView packages/core/src/render3/interfaces/view.ts The mutable per-instance array — the heart of Ivy.
TView same Static template metadata shared across instances.
ɵɵelementStart, ɵɵproperty, ɵɵtext, ɵɵtemplate, ... packages/core/src/render3/instructions/ The instructions emitted by the compiler.
ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdefinePipe packages/core/src/render3/definition.ts The static ɵcmp/ɵdir/ɵpipe factories the compiler attaches to classes.
ApplicationRef packages/core/src/application/application_ref.ts The root reference; owns tick() and root component lifecycle.
Injector / EnvironmentInjector packages/core/src/di/ DI lookup. The runtime hot path is in render3/di.ts.
signal, computed, effect packages/core/primitives/signals/ The reactivity primitives.
input, output, model, viewChild, contentChild packages/core/src/authoring/ Signal-based component authoring APIs.
inject() packages/core/src/di/inject.ts The function form of constructor injection.
provideClientHydration packages/core/src/hydration/api.ts The provider that opts an app into hydration.
RuntimeError / formatRuntimeError packages/core/src/errors.ts The standard error-with-code shape.

How a component runs

sequenceDiagram
  participant Boot as bootstrapApplication
  participant App as ApplicationRef
  participant CD as scheduler
  participant Tmpl as template fn (compiled)
  participant DOM
  Boot->>App: createApplication() + create root component
  App->>App: allocate root LView
  App->>Tmpl: render(LView, RenderFlags.Create)
  Tmpl->>DOM: ɵɵelementStart, ɵɵtext, ɵɵproperty, ...
  loop on each tick
    CD->>App: tick()
    App->>Tmpl: render(LView, RenderFlags.Update)
    Tmpl->>DOM: update bindings whose values changed
  end

For a deeper account of LView/TView and instructions, see systems/ivy-runtime.

Integration points

  • Compiler input. The decorator metadata exposed here (e.g., the shape of @Component) is what ngtsc parses and translates. Any new authoring API requires coordinated changes in @angular/compiler-cli and often @angular/compiler.
  • Renderer. @angular/platform-browser and @angular/platform-server provide concrete Renderer2 implementations and DOM event handling. The runtime's hydration code calls into them via well-known tokens.
  • Forms / Router / etc. Domain libraries inject Injector and ApplicationRef, register providers, and rely on signals or RxJS for reactivity. They do not import render3/* directly.
  • DevTools. packages/core/src/render3/debug and the setGlobalUtils shim register the ng.* console helpers that DevTools and the in-page debug API use.

Subsystems worth knowing

Internal docs in the package

The package keeps several internal design notes alongside the code. They predate this wiki and are still useful:

Migrations

packages/core/schematics/migrations/ is one of the largest schematic suites in the repo. Recent additions:

  • control-flow-migration — converts *ngIf/*ngFor/*ngSwitch to @if/@for/@switch.
  • signal-input-migration — converts @Input() to input().
  • signal-output-migration — converts @Output() to output().
  • signal-queries-migration — converts @ViewChild/@ContentChild to viewChild/contentChild.
  • inject-migration — converts constructor injection to inject() calls.

Each migration ships with the framework and runs via ng update @angular/core.

Entry points for modification

  • A new component-authoring API: start in packages/core/src/authoring/, then extend ngtsc/annotations/component to recognize the new metadata, then add the matching codegen in @angular/compiler/src/render3/view.
  • A new instruction: add it under render3/instructions/, expose it via render3/index.ts, and emit it from the compiler's view-IR-to-output translator.
  • A new lifecycle hook: extend render3/hooks.ts and the matching feature flag in definition.ts.

The complete reference for the Ivy mental model is the reference-core project skill — open it via the Skill tool when working in this package.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

@angular/core – Angular wiki | Factory