What is @angular/compiler?
The @angular/compiler package is a core part of the Angular framework that is responsible for compiling Angular templates into JavaScript code that can be executed by the browser. It takes the templates and annotations provided in Angular components and generates code that represents the structure and behavior of the application.
What are @angular/compiler's main functionalities?
Template Compilation
This feature allows you to compile Angular components and modules dynamically at runtime. The code sample demonstrates how to use the JIT compiler to compile a module and its components asynchronously.
import { Compiler, COMPILER_OPTIONS, CompilerFactory } from '@angular/core';
import { JitCompilerFactory } from '@angular/platform-browser-dynamic';
// Get a reference to the JIT compiler factory
const compilerFactory: CompilerFactory = platformBrowserDynamic().injector.get(CompilerFactory);
const compiler = compilerFactory.createCompiler();
// Compile a component dynamically
compiler.compileModuleAndAllComponentsAsync(DynamicModule)
.then(compiled => {
const moduleRef = compiled.ngModuleFactory.create(this.injector);
const componentFactory = compiled.componentFactories[0];
this.container.createComponent(componentFactory);
});
AOT Compilation
Ahead-of-Time (AOT) compilation converts Angular HTML and TypeScript code into efficient JavaScript code during the build process, before the browser downloads and runs the code. This code sample shows how to bootstrap an Angular application using the AOT-compiled module factory.
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
import { AppModuleNgFactory } from './app/app.module.ngfactory';
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
Other packages similar to @angular/compiler
babel
Babel is a JavaScript compiler that converts ECMAScript 2015+ code into a backwards-compatible version of JavaScript that can be run by older JavaScript engines. Babel is similar to @angular/compiler in that it performs code transformation, but it is not specific to Angular and does not compile Angular templates.
typescript
TypeScript is a superset of JavaScript that compiles to plain JavaScript. It is similar to @angular/compiler in that it performs a compilation step, but TypeScript focuses on type-checking and converting TypeScript code to JavaScript, rather than compiling framework-specific templates.
vue-template-compiler
The vue-template-compiler package is used to compile Vue.js templates into render functions. It is similar to @angular/compiler as both are used for compiling framework-specific templates, but they target different frameworks (Vue.js vs Angular).
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT
19.2.0-next.1 (2025-01-29)
core
| Commit | Type | Description |
| -- | -- | -- |
| 168516462a9 | feat | support default value in resource()
(#59655) |
| 6c92d653493 | fix | add hasValue
narrowing to ResourceRef
(#59708) |
| 96e602ebe9c | fix | cancel in-progress request when same value is assigned (#59280) |
| cf9054248d1 | fix | check whether application is destroyed before printing hydration stats (#59716) |
| 82876242e55 | fix | ensure type is preserved during HMR (#59700) |
| 127fc0dc847 | fix | fix resource()
's previous.state
(#59708) |
| f862ace1819 | fix | fixes test timer-based test flakiness in CI (#59674) |
elements
| Commit | Type | Description |
| -- | -- | -- |
| 0c1ecb453c8 | fix | not setting initial value on signal-based input (#59773) |
platform-browser
| Commit | Type | Description |
| -- | -- | -- |
| e6cb411e439 | fix | automatically disable animations on the server (#59762) |
| 6b09716754b | fix | prepend baseHref
to sourceMappingURL
in CSS content (#59730) |
| fd7ee47bf70 | fix | Update pseudoevent created by createMouseSpecialEvent to populate _originalEvent
property (#59690) |
| 65cf061feb4 | fix | Update pseudoevent created by createMouseSpecialEvent to populate _originalEvent
property (#59690) |
| af9d74710c4 | fix | Update pseudoevent created by createMouseSpecialEvent to populate _originalEvent
property (#59690) |
platform-server
| Commit | Type | Description |
| -- | -- | -- |
| fc5d187da5e | fix | decouple server from animations module (#59762) |
router
| Commit | Type | Description |
| -- | -- | -- |
| c7b6e1107c6 | fix | prevent error handling when injector is destroyed (#59457) |
service-worker
| Commit | Type | Description |
| -- | -- | -- |
| e2987a1d4ab | fix | add missing rxjs
peer dependency (#59747) |
<!-- CHANGELOG SPLIT MARKER -->
<a name="19.1.4"></a>