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
ngtscrecognizes (@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
deferblock 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 surfaceprimitives/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
endFor 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 whatngtscparses and translates. Any new authoring API requires coordinated changes in@angular/compiler-cliand often@angular/compiler. - Renderer.
@angular/platform-browserand@angular/platform-serverprovide concreteRenderer2implementations and DOM event handling. The runtime's hydration code calls into them via well-known tokens. - Forms / Router / etc. Domain libraries inject
InjectorandApplicationRef, register providers, and rely on signals or RxJS for reactivity. They do not importrender3/*directly. - DevTools.
packages/core/src/render3/debugand thesetGlobalUtilsshim register theng.*console helpers that DevTools and the in-page debug API use.
Subsystems worth knowing
- Change detection — implemented in
render3/state.ts,render3/instructions/change_detection.ts, and the application scheduler insrc/application/. Seesystems/change-detection. - DI hot path —
render3/di.tsis the bloom-filter element-injector lookup. Distinct from the definition-side DI insrc/di/. - Signals —
primitives/signalsis the standalone primitive layer;render3/reactivity/glues signals into LViews. - Hydration —
src/hydrationplusrender3/hydration/. Seesystems/hydration. - Defer blocks —
src/defer. Seefeatures/deferrable-views. - Sanitization —
render3/sanitization/is the bindings-time XSS filter, complementingDomSanitizerinplatform-browser.
Internal docs in the package
The package keeps several internal design notes alongside the code. They predate this wiki and are still useful:
packages/core/src/render3/PERF_NOTES.md— performance constraints on the hot path.packages/core/src/render3/VIEW_DATA.md— the LView/TView memory layout.packages/core/src/render3/CODE_GEN_API.md— the contract between the compiler and the runtime.packages/core/src/render3/STORING_METADATA_IN_D.TS.md— how Ivy persists metadata for downstream compilation.packages/core/src/render3/TREE_SHAKING.md— what makes Ivy tree-shakable.
Migrations
packages/core/schematics/migrations/ is one of the largest schematic suites in the repo. Recent additions:
control-flow-migration— converts*ngIf/*ngFor/*ngSwitchto@if/@for/@switch.signal-input-migration— converts@Input()toinput().signal-output-migration— converts@Output()tooutput().signal-queries-migration— converts@ViewChild/@ContentChildtoviewChild/contentChild.inject-migration— converts constructor injection toinject()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 extendngtsc/annotations/componentto 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 viarender3/index.ts, and emit it from the compiler's view-IR-to-output translator. - A new lifecycle hook: extend
render3/hooks.tsand the matching feature flag indefinition.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.