/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/core/src/linker/compiler.ts
97 строк
2 KB
Matthieu Riegler
refactor(core): use the `@Service` decorator where possible.
08 май 2026, 02:03
08 май 2026, 02:03
a7dab60
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Service} from '../di'; import {InjectionToken} from '../di/injection_token'; import {StaticProvider} from '../di/interface/provider'; import {Type} from '../interface/type'; import {ViewEncapsulation} from '../metadata/view'; import {NgModuleFactory as NgModuleFactoryR3} from '../render3/ng_module_ref'; import {NgModuleFactory} from './ng_module_factory'; /** * Low-level service for running the angular compiler during runtime * to create {@link AbstractComponentFactory}s, which * can later be used to create and render a Component instance. * * Each `@NgModule` provides an own `Compiler` to its injector, * that will use the directives/pipes of the ng module for compilation * of components. * * @publicApi * * @deprecated * Ivy JIT mode doesn't require accessing this symbol. */ @Service() export class Compiler { /** * Compiles the given NgModule and all of its components. All templates of the components * have to be inlined. */ compileModuleSync<T>(moduleType: Type<T>): NgModuleFactory<T> { return new NgModuleFactoryR3(moduleType); } /** * Compiles the given NgModule and all of its components */ compileModuleAsync<T>(moduleType: Type<T>): Promise<NgModuleFactory<T>> { return Promise.resolve(this.compileModuleSync(moduleType)); } /** * Clears all caches. */ clearCache(): void {} /** * Clears the cache for the given component/ngModule. */ clearCacheFor(type: Type<any>) {} /** * Returns the id for a given NgModule, if one is defined and known to the compiler. */ getModuleId(moduleType: Type<any>): string | undefined { return undefined; } } /** * Options for creating a compiler. * * @publicApi */ export type CompilerOptions = { defaultEncapsulation?: ViewEncapsulation; providers?: StaticProvider[]; preserveWhitespaces?: boolean; }; /** * Token to provide CompilerOptions in the platform injector. * * @publicApi */ export const COMPILER_OPTIONS = new InjectionToken<CompilerOptions[]>( typeof ngDevMode !== 'undefined' && ngDevMode ? 'compilerOptions' : '', ); /** * A factory for creating a Compiler * * @publicApi * * @deprecated * Ivy JIT mode doesn't require accessing this symbol. */ export abstract class CompilerFactory { abstract createCompiler(options?: CompilerOptions[]): Compiler; }