2016-06-23 09:47:54 -07: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-08-16 09:00:03 -07:00
|
|
|
import {CompileIdentifierMetadata} from './compile_metadata';
|
|
|
|
import {MissingTranslationStrategy, ViewEncapsulation} from './core';
|
|
|
|
import {Identifiers} from './identifiers';
|
|
|
|
import * as o from './output/output_ast';
|
2017-07-28 15:58:28 +02:00
|
|
|
import {noUndefined} from './util';
|
2017-02-02 15:01:35 -08:00
|
|
|
|
2016-01-06 14:13:44 -08:00
|
|
|
export class CompilerConfig {
|
2017-03-24 09:59:58 -07:00
|
|
|
public defaultEncapsulation: ViewEncapsulation|null;
|
2017-01-10 19:07:03 -08: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 10:06:40 -07:00
|
|
|
public useJit: boolean;
|
2017-08-16 09:00:03 -07:00
|
|
|
public jitDevMode: boolean;
|
2017-03-24 09:59:58 -07:00
|
|
|
public missingTranslation: MissingTranslationStrategy|null;
|
2017-07-28 15:58:28 +02:00
|
|
|
public preserveWhitespaces: boolean;
|
2016-04-03 08:34:44 +09:00
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
constructor(
|
2017-08-16 09:00:03 -07:00
|
|
|
{defaultEncapsulation = ViewEncapsulation.Emulated, useJit = true, jitDevMode = false,
|
|
|
|
missingTranslation, enableLegacyTemplate, preserveWhitespaces}: {
|
2016-06-13 10:06:40 -07:00
|
|
|
defaultEncapsulation?: ViewEncapsulation,
|
2017-01-25 23:26:49 -08:00
|
|
|
useJit?: boolean,
|
2017-08-16 09:00:03 -07:00
|
|
|
jitDevMode?: boolean,
|
2017-01-25 23:26:49 -08:00
|
|
|
missingTranslation?: MissingTranslationStrategy,
|
2017-01-10 19:07:03 -08:00
|
|
|
enableLegacyTemplate?: boolean,
|
2017-07-28 15:58:28 +02:00
|
|
|
preserveWhitespaces?: boolean
|
2016-06-13 10:06:40 -07:00
|
|
|
} = {}) {
|
2016-04-03 08:34:44 +09:00
|
|
|
this.defaultEncapsulation = defaultEncapsulation;
|
2017-03-24 09:59:58 -07:00
|
|
|
this.useJit = !!useJit;
|
2017-08-16 09:00:03 -07:00
|
|
|
this.jitDevMode = !!jitDevMode;
|
2017-03-24 09:59:58 -07:00
|
|
|
this.missingTranslation = missingTranslation || null;
|
2017-01-10 19:07:03 -08:00
|
|
|
this.enableLegacyTemplate = enableLegacyTemplate !== false;
|
2017-07-28 15:58:28 +02:00
|
|
|
this.preserveWhitespaces = preserveWhitespacesDefault(noUndefined(preserveWhitespaces));
|
2016-01-06 14:13:44 -08:00
|
|
|
}
|
|
|
|
}
|
2017-07-28 15:58:28 +02:00
|
|
|
|
|
|
|
export function preserveWhitespacesDefault(
|
|
|
|
preserveWhitespacesOption: boolean | null, defaultSetting = true): boolean {
|
|
|
|
return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption;
|
|
|
|
}
|