feat(compiler): integrate compiler with view engine - main integration tests work (#14284)
Part of #14013 PR Close #14284
This commit is contained in:

committed by
Miško Hevery

parent
dfe29934b6
commit
baa654a234
@ -6,12 +6,12 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Compiler, ComponentFactory, Injector, ModuleWithComponentFactories, NgModuleFactory, Type} from '@angular/core';
|
||||
import {Compiler, ComponentFactory, Inject, Injector, ModuleWithComponentFactories, NgModuleFactory, Type} from '@angular/core';
|
||||
|
||||
import {AnimationCompiler} from '../animation/animation_compiler';
|
||||
import {AnimationParser} from '../animation/animation_parser';
|
||||
import {CompileDirectiveMetadata, CompileIdentifierMetadata, CompileNgModuleMetadata, ProviderMeta, ProxyClass, createHostComponentMeta, identifierName} from '../compile_metadata';
|
||||
import {CompilerConfig} from '../config';
|
||||
import {CompilerConfig, USE_VIEW_ENGINE} from '../config';
|
||||
import {DirectiveWrapperCompiler} from '../directive_wrapper_compiler';
|
||||
import {stringify} from '../facade/lang';
|
||||
import {CompilerInjectable} from '../injectable';
|
||||
@ -50,7 +50,8 @@ export class JitCompiler implements Compiler {
|
||||
private _templateParser: TemplateParser, private _styleCompiler: StyleCompiler,
|
||||
private _viewCompiler: ViewCompiler, private _ngModuleCompiler: NgModuleCompiler,
|
||||
private _directiveWrapperCompiler: DirectiveWrapperCompiler,
|
||||
private _compilerConfig: CompilerConfig, private _animationParser: AnimationParser) {}
|
||||
private _compilerConfig: CompilerConfig, private _animationParser: AnimationParser,
|
||||
@Inject(USE_VIEW_ENGINE) private _useViewEngine: boolean) {}
|
||||
|
||||
get injector(): Injector { return this._injector; }
|
||||
|
||||
@ -244,6 +245,9 @@ export class JitCompiler implements Compiler {
|
||||
|
||||
private _compileDirectiveWrapper(
|
||||
dirMeta: CompileDirectiveMetadata, moduleMeta: CompileNgModuleMetadata): void {
|
||||
if (this._useViewEngine) {
|
||||
return;
|
||||
}
|
||||
const compileResult = this._directiveWrapperCompiler.compile(dirMeta);
|
||||
const statements = compileResult.statements;
|
||||
let directiveWrapperClass: any;
|
||||
|
@ -9,7 +9,7 @@
|
||||
import {COMPILER_OPTIONS, Compiler, CompilerFactory, CompilerOptions, Inject, InjectionToken, MissingTranslationStrategy, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, ReflectiveInjector, TRANSLATIONS, TRANSLATIONS_FORMAT, Type, ViewEncapsulation, createPlatformFactory, isDevMode, platformCore} from '@angular/core';
|
||||
|
||||
import {AnimationParser} from '../animation/animation_parser';
|
||||
import {CompilerConfig} from '../config';
|
||||
import {CompilerConfig, USE_VIEW_ENGINE} from '../config';
|
||||
import {DirectiveNormalizer} from '../directive_normalizer';
|
||||
import {DirectiveResolver} from '../directive_resolver';
|
||||
import {DirectiveWrapperCompiler} from '../directive_wrapper_compiler';
|
||||
@ -31,6 +31,7 @@ import {SummaryResolver} from '../summary_resolver';
|
||||
import {TemplateParser} from '../template_parser/template_parser';
|
||||
import {DEFAULT_PACKAGE_URL_PROVIDER, UrlResolver} from '../url_resolver';
|
||||
import {ViewCompiler} from '../view_compiler/view_compiler';
|
||||
import {ViewCompilerNext} from '../view_compiler_next/view_compiler';
|
||||
|
||||
import {JitCompiler} from './compiler';
|
||||
|
||||
@ -42,6 +43,11 @@ const _NO_RESOURCE_LOADER: ResourceLoader = {
|
||||
|
||||
const baseHtmlParser = new InjectionToken('HtmlParser');
|
||||
|
||||
function viewCompilerFactory(
|
||||
useViewEngine: boolean, cc: CompilerConfig, sr: ElementSchemaRegistry) {
|
||||
return useViewEngine ? new ViewCompilerNext(cc, sr) : new ViewCompiler(cc, sr);
|
||||
}
|
||||
|
||||
/**
|
||||
* A set of providers that provide `JitCompiler` and its dependencies to use for
|
||||
* template compilation.
|
||||
@ -81,7 +87,12 @@ export const COMPILER_PROVIDERS: Array<any|Type<any>|{[k: string]: any}|any[]> =
|
||||
CompileMetadataResolver,
|
||||
DEFAULT_PACKAGE_URL_PROVIDER,
|
||||
StyleCompiler,
|
||||
ViewCompiler,
|
||||
{provide: USE_VIEW_ENGINE, useValue: false},
|
||||
{
|
||||
provide: ViewCompiler,
|
||||
useFactory: viewCompilerFactory,
|
||||
deps: [USE_VIEW_ENGINE, CompilerConfig, ElementSchemaRegistry]
|
||||
},
|
||||
NgModuleCompiler,
|
||||
DirectiveWrapperCompiler,
|
||||
{provide: CompilerConfig, useValue: new CompilerConfig()},
|
||||
|
Reference in New Issue
Block a user