2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. 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.io/license
|
|
|
|
*/
|
|
|
|
|
2017-02-02 18:01:35 -05:00
|
|
|
import {InjectionToken, MissingTranslationStrategy, ViewEncapsulation, isDevMode} from '@angular/core';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-01-06 17:13:44 -05:00
|
|
|
import {CompileIdentifierMetadata} from './compile_metadata';
|
2016-11-23 12:42:19 -05:00
|
|
|
import {Identifiers, createIdentifier} from './identifiers';
|
2016-01-06 17:13:44 -05:00
|
|
|
|
2017-02-02 18:01:35 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Temporal switch for the compiler to use the new view engine,
|
|
|
|
* until it is fully integrated.
|
|
|
|
*
|
|
|
|
* Only works in Jit for now.
|
|
|
|
*/
|
|
|
|
export const USE_VIEW_ENGINE = new InjectionToken<boolean>('UseViewEngine');
|
|
|
|
|
2016-01-06 17:13:44 -05:00
|
|
|
export class CompilerConfig {
|
|
|
|
public renderTypes: RenderTypes;
|
2016-04-02 19:34:44 -04:00
|
|
|
public defaultEncapsulation: ViewEncapsulation;
|
2017-01-10 22:07:03 -05:00
|
|
|
// Whether to support the `<template>` tag and the `template` attribute to define angular
|
|
|
|
// templates. They have been deprecated in 4.x, `<ng-template>` should be used instead.
|
|
|
|
public enableLegacyTemplate: boolean;
|
2016-06-13 13:06:40 -04:00
|
|
|
public useJit: boolean;
|
2017-02-17 11:56:36 -05:00
|
|
|
public useViewEngine: boolean;
|
2017-01-26 02:26:49 -05:00
|
|
|
public missingTranslation: MissingTranslationStrategy;
|
2016-04-02 19:34:44 -04:00
|
|
|
|
2017-01-10 22:07:03 -05:00
|
|
|
private _genDebugInfo: boolean;
|
|
|
|
private _logBindingUpdate: boolean;
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
constructor(
|
2016-06-13 13:06:40 -04:00
|
|
|
{renderTypes = new DefaultRenderTypes(), defaultEncapsulation = ViewEncapsulation.Emulated,
|
2017-01-10 22:07:03 -05:00
|
|
|
genDebugInfo, logBindingUpdate, useJit = true, missingTranslation, useViewEngine,
|
|
|
|
enableLegacyTemplate}: {
|
2016-06-13 13:06:40 -04:00
|
|
|
renderTypes?: RenderTypes,
|
|
|
|
defaultEncapsulation?: ViewEncapsulation,
|
|
|
|
genDebugInfo?: boolean,
|
|
|
|
logBindingUpdate?: boolean,
|
2017-01-26 02:26:49 -05:00
|
|
|
useJit?: boolean,
|
|
|
|
missingTranslation?: MissingTranslationStrategy,
|
2017-01-10 22:07:03 -05:00
|
|
|
useViewEngine?: boolean,
|
|
|
|
enableLegacyTemplate?: boolean,
|
2016-06-13 13:06:40 -04:00
|
|
|
} = {}) {
|
2016-01-06 17:13:44 -05:00
|
|
|
this.renderTypes = renderTypes;
|
2016-04-02 19:34:44 -04:00
|
|
|
this.defaultEncapsulation = defaultEncapsulation;
|
2016-06-17 17:09:19 -04:00
|
|
|
this._genDebugInfo = genDebugInfo;
|
|
|
|
this._logBindingUpdate = logBindingUpdate;
|
2016-06-13 13:06:40 -04:00
|
|
|
this.useJit = useJit;
|
2017-01-26 02:26:49 -05:00
|
|
|
this.missingTranslation = missingTranslation;
|
2017-02-21 11:15:33 -05:00
|
|
|
this.useViewEngine = true;
|
2017-01-10 22:07:03 -05:00
|
|
|
this.enableLegacyTemplate = enableLegacyTemplate !== false;
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|
2016-06-17 17:09:19 -04:00
|
|
|
|
|
|
|
get genDebugInfo(): boolean {
|
|
|
|
return this._genDebugInfo === void 0 ? isDevMode() : this._genDebugInfo;
|
|
|
|
}
|
|
|
|
get logBindingUpdate(): boolean {
|
|
|
|
return this._logBindingUpdate === void 0 ? isDevMode() : this._logBindingUpdate;
|
|
|
|
}
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Types used for the renderer.
|
|
|
|
* Can be replaced to specialize the generated output to a specific renderer
|
|
|
|
* to help tree shaking.
|
|
|
|
*/
|
|
|
|
export abstract class RenderTypes {
|
2017-01-26 01:32:32 -05:00
|
|
|
abstract get renderer(): CompileIdentifierMetadata;
|
|
|
|
abstract get renderText(): CompileIdentifierMetadata;
|
|
|
|
abstract get renderElement(): CompileIdentifierMetadata;
|
|
|
|
abstract get renderComment(): CompileIdentifierMetadata;
|
|
|
|
abstract get renderNode(): CompileIdentifierMetadata;
|
|
|
|
abstract get renderEvent(): CompileIdentifierMetadata;
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export class DefaultRenderTypes implements RenderTypes {
|
2016-11-23 12:42:19 -05:00
|
|
|
get renderer() { return createIdentifier(Identifiers.Renderer); };
|
2016-06-28 14:35:59 -04:00
|
|
|
renderText: any = null;
|
|
|
|
renderElement: any = null;
|
|
|
|
renderComment: any = null;
|
|
|
|
renderNode: any = null;
|
|
|
|
renderEvent: any = null;
|
2016-01-06 17:13:44 -05:00
|
|
|
}
|