diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index 87cfa0e1ab..0248e1daa7 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -151,19 +151,25 @@ export class CodeGenerator { const staticReflector = new StaticReflector(reflectorHost); StaticAndDynamicReflectionCapabilities.install(staticReflector); const htmlParser = new HtmlParser(); - const config = new compiler.CompilerConfig(true, true, true); + const config = new compiler.CompilerConfig({ + genDebugInfo: true, + defaultEncapsulation: ViewEncapsulation.Emulated, + logBindingUpdate: false, + useJit: false, + platformDirectives: [], + platformPipes: [] + }); const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config); const parser = new Parser(new Lexer()); const tmplParser = new TemplateParser( parser, new DomElementSchemaRegistry(), htmlParser, /*console*/ null, []); const offlineCompiler = new compiler.OfflineCompiler( - normalizer, tmplParser, new StyleCompiler(urlResolver), - new ViewCompiler(new compiler.CompilerConfig(true, true, true)), + normalizer, tmplParser, new StyleCompiler(urlResolver), new ViewCompiler(config), new TypeScriptEmitter(reflectorHost), xhr); const resolver = new CompileMetadataResolver( new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), - new compiler.ViewResolver(staticReflector), null, null, staticReflector); + new compiler.ViewResolver(staticReflector), config, staticReflector); return new CodeGenerator( options, program, compilerHost, staticReflector, resolver, offlineCompiler, reflectorHost); diff --git a/modules/@angular/compiler-cli/src/extract_i18n.ts b/modules/@angular/compiler-cli/src/extract_i18n.ts index 82c96112ad..ca8f28d954 100644 --- a/modules/@angular/compiler-cli/src/extract_i18n.ts +++ b/modules/@angular/compiler-cli/src/extract_i18n.ts @@ -11,6 +11,7 @@ import * as ts from 'typescript'; import * as tsc from '@angular/tsc-wrapped'; import * as path from 'path'; import * as compiler from '@angular/compiler'; +import {ViewEncapsulation} from '@angular/core'; import {StaticReflector} from './static_reflector'; import {CompileMetadataResolver, HtmlParser, DirectiveNormalizer, Lexer, Parser, TemplateParser, DomElementSchemaRegistry, StyleCompiler, ViewCompiler, TypeScriptEmitter, MessageExtractor, removeDuplicates, ExtractionResult, Message, ParseError, serializeXmb,} from './compiler_private'; @@ -136,7 +137,14 @@ class Extractor { const staticReflector = new StaticReflector(reflectorHost); StaticAndDynamicReflectionCapabilities.install(staticReflector); const htmlParser = new HtmlParser(); - const config = new compiler.CompilerConfig(true, true, true); + const config = new compiler.CompilerConfig({ + genDebugInfo: true, + defaultEncapsulation: ViewEncapsulation.Emulated, + logBindingUpdate: false, + useJit: false, + platformDirectives: [], + platformPipes: [] + }); const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config); const parser = new Parser(new Lexer()); const tmplParser = new TemplateParser( @@ -147,7 +155,7 @@ class Extractor { new TypeScriptEmitter(reflectorHost), xhr); const resolver = new CompileMetadataResolver( new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), - new compiler.ViewResolver(staticReflector), null, null, staticReflector); + new compiler.ViewResolver(staticReflector), config, staticReflector); // TODO(vicb): handle implicit const extractor = new MessageExtractor(htmlParser, parser, [], {}); diff --git a/modules/@angular/compiler/src/compiler.ts b/modules/@angular/compiler/src/compiler.ts index 36f18afece..6b40a79e00 100644 --- a/modules/@angular/compiler/src/compiler.ts +++ b/modules/@angular/compiler/src/compiler.ts @@ -31,10 +31,6 @@ import {ViewResolver} from './view_resolver'; import {DirectiveResolver} from './directive_resolver'; import {PipeResolver} from './pipe_resolver'; -function _createCompilerConfig() { - return new CompilerConfig(assertionsEnabled(), false, true); -} - /** * A set of providers that provide `RuntimeCompiler` and its dependencies to use for * template compilation. @@ -43,7 +39,7 @@ export const COMPILER_PROVIDERS: Array = /*@ts2dart_const*/[ Lexer, Parser, HtmlParser, TemplateParser, DirectiveNormalizer, CompileMetadataResolver, DEFAULT_PACKAGE_URL_PROVIDER, StyleCompiler, ViewCompiler, - /*@ts2dart_Provider*/ {provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []}, + /*@ts2dart_Provider*/ {provide: CompilerConfig, useValue: new CompilerConfig()}, RuntimeCompiler, /*@ts2dart_Provider*/ {provide: ComponentResolver, useExisting: RuntimeCompiler}, DomElementSchemaRegistry, diff --git a/modules/@angular/compiler/src/config.ts b/modules/@angular/compiler/src/config.ts index d43122e043..dafa196dfa 100644 --- a/modules/@angular/compiler/src/config.ts +++ b/modules/@angular/compiler/src/config.ts @@ -1,7 +1,7 @@ import {ViewEncapsulation} from '@angular/core'; import {unimplemented} from '../src/facade/exceptions'; -import {Type, isBlank} from '../src/facade/lang'; +import {Type, assertionsEnabled, isBlank} from '../src/facade/lang'; import {CompileIdentifierMetadata} from './compile_metadata'; import {Identifiers} from './identifiers'; @@ -9,19 +9,31 @@ import {Identifiers} from './identifiers'; export class CompilerConfig { public renderTypes: RenderTypes; public defaultEncapsulation: ViewEncapsulation; + public genDebugInfo: boolean; + public logBindingUpdate: boolean; + public useJit: boolean; + public platformDirectives: any[]; + public platformPipes: any[]; constructor( - public genDebugInfo: boolean, public logBindingUpdate: boolean, public useJit: boolean, - renderTypes: RenderTypes = null, defaultEncapsulation: ViewEncapsulation = null, - public platformDirectives: any[] = [], public platformPipes: any[] = []) { - if (isBlank(renderTypes)) { - renderTypes = new DefaultRenderTypes(); - } + {renderTypes = new DefaultRenderTypes(), defaultEncapsulation = ViewEncapsulation.Emulated, + genDebugInfo = assertionsEnabled(), logBindingUpdate = assertionsEnabled(), useJit = true, + platformDirectives = [], platformPipes = []}: { + renderTypes?: RenderTypes, + defaultEncapsulation?: ViewEncapsulation, + genDebugInfo?: boolean, + logBindingUpdate?: boolean, + useJit?: boolean, + platformDirectives?: any[], + platformPipes?: any[] + } = {}) { this.renderTypes = renderTypes; - if (isBlank(defaultEncapsulation)) { - defaultEncapsulation = ViewEncapsulation.Emulated; - } this.defaultEncapsulation = defaultEncapsulation; + this.genDebugInfo = genDebugInfo; + this.logBindingUpdate = logBindingUpdate; + this.useJit = useJit; + this.platformDirectives = platformDirectives; + this.platformPipes = platformPipes; } } diff --git a/modules/@angular/compiler/test/metadata_resolver_spec.ts b/modules/@angular/compiler/test/metadata_resolver_spec.ts index 246996b412..290a5e56ef 100644 --- a/modules/@angular/compiler/test/metadata_resolver_spec.ts +++ b/modules/@angular/compiler/test/metadata_resolver_spec.ts @@ -72,11 +72,11 @@ export function main() { })); describe('platform directives', () => { - beforeEachProviders( - () => [{ - provide: CompilerConfig, - useValue: new CompilerConfig(true, false, true, null, null, [ADirective]) - }]); + beforeEachProviders(() => [{ + provide: CompilerConfig, + useValue: new CompilerConfig( + {genDebugInfo: true, platformDirectives: [ADirective]}) + }]); it('should include platform directives when available', inject([CompileMetadataResolver], (resolver: CompileMetadataResolver) => { diff --git a/modules/@angular/compiler/test/offline_compiler_util.ts b/modules/@angular/compiler/test/offline_compiler_util.ts index f68da7e2f3..5336ccb3f6 100644 --- a/modules/@angular/compiler/test/offline_compiler_util.ts +++ b/modules/@angular/compiler/test/offline_compiler_util.ts @@ -40,15 +40,13 @@ function _createOfflineCompiler(xhr: MockXHR, emitter: OutputEmitter): OfflineCo var urlResolver = createOfflineCompileUrlResolver(); xhr.when(`${THIS_MODULE_PATH}/offline_compiler_compa.html`, 'Hello World {{user}}!'); var htmlParser = new HtmlParser(); - var config = new CompilerConfig(true, true, true); - var normalizer = - new DirectiveNormalizer(xhr, urlResolver, htmlParser, new CompilerConfig(true, true, true)); + var config = new CompilerConfig({genDebugInfo: true, useJit: true}); + var normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config); return new OfflineCompiler( normalizer, new TemplateParser( new Parser(new Lexer()), new MockSchemaRegistry({}, {}), htmlParser, new Console(), []), - new StyleCompiler(urlResolver), new ViewCompiler(new CompilerConfig(true, true, true)), - emitter, xhr); + new StyleCompiler(urlResolver), new ViewCompiler(config), emitter, xhr); } export function compileComp( diff --git a/modules/@angular/core/test/animation/animation_integration_spec.ts b/modules/@angular/core/test/animation/animation_integration_spec.ts index 5b81d82b55..892edc5edd 100644 --- a/modules/@angular/core/test/animation/animation_integration_spec.ts +++ b/modules/@angular/core/test/animation/animation_integration_spec.ts @@ -15,25 +15,23 @@ import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe export function main() { if (IS_DART) { - declareTests(); + declareTests({useJit: false}); } else { - describe('jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, true)}]); - declareTests(); - }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, false)}]); - declareTests(); - }); + describe('no jit', () => { declareTests({useJit: false}); }); } } -function declareTests() { +function declareTests({useJit}: {useJit: boolean}) { describe('animation tests', function() { - beforeEachProviders(() => [{provide: AnimationDriver, useClass: MockAnimationDriver}]); + beforeEachProviders( + () => + [{ + provide: CompilerConfig, + useValue: new CompilerConfig({genDebugInfo: true, useJit: useJit}) + }, + {provide: AnimationDriver, useClass: MockAnimationDriver}]); var makeAnimationCmp = (tcb: TestComponentBuilder, tpl: string, diff --git a/modules/@angular/core/test/linker/integration_spec.ts b/modules/@angular/core/test/linker/integration_spec.ts index f07fadc156..254749443d 100644 --- a/modules/@angular/core/test/linker/integration_spec.ts +++ b/modules/@angular/core/test/linker/integration_spec.ts @@ -34,26 +34,24 @@ const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement'); export function main() { if (IS_DART) { - declareTests(false); + declareTests({useJit: false}); } else { - describe('jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, true)}]); - declareTests(true); - }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, false)}]); - declareTests(false); - }); + describe('no jit', () => { declareTests({useJit: false}); }); } } -function declareTests(isJit: boolean) { +function declareTests({useJit}: {useJit: boolean}) { describe('integration tests', function() { - beforeEachProviders(() => [{provide: ANCHOR_ELEMENT, useValue: el('
')}]); + beforeEachProviders( + () => + [{ + provide: CompilerConfig, + useValue: new CompilerConfig({genDebugInfo: true, useJit: useJit}) + }, + {provide: ANCHOR_ELEMENT, useValue: el('
')}]); describe('react to record changes', function() { it('should consume text node changes', @@ -1788,8 +1786,10 @@ function declareTests(isJit: boolean) { }); describe('logging property updates', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, true, isJit)}]); + beforeEachProviders(() => [{ + provide: CompilerConfig, + useValue: new CompilerConfig({genDebugInfo: true, useJit: useJit}) + }]); it('should reflect property values as attributes', inject( diff --git a/modules/@angular/core/test/linker/regression_integration_spec.ts b/modules/@angular/core/test/linker/regression_integration_spec.ts index c1cc6b73e9..71eb42383b 100644 --- a/modules/@angular/core/test/linker/regression_integration_spec.ts +++ b/modules/@angular/core/test/linker/regression_integration_spec.ts @@ -10,23 +10,15 @@ import {CompilerConfig} from '@angular/compiler'; export function main() { if (IS_DART) { - declareTests(false); + declareTests({useJit: false}); } else { - describe('jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, true)}]); - declareTests(true); - }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, false)}]); - declareTests(false); - }); + describe('no jit', () => { declareTests({useJit: false}); }); } } -function declareTests(isJit: boolean) { +function declareTests({useJit}: {useJit: boolean}) { // Place to put reproductions for regressions describe('regressions', () => { @@ -34,7 +26,8 @@ function declareTests(isJit: boolean) { beforeEachProviders( () => [{ provide: CompilerConfig, - useValue: new CompilerConfig(true, false, isJit, null, null, [PlatformPipe]) + useValue: new CompilerConfig( + {genDebugInfo: true, useJit: useJit, platformPipes: [PlatformPipe]}) }]); it('should overwrite them by custom pipes', diff --git a/modules/@angular/core/test/linker/security_integration_spec.ts b/modules/@angular/core/test/linker/security_integration_spec.ts index 5cef0366d5..80b57ff701 100644 --- a/modules/@angular/core/test/linker/security_integration_spec.ts +++ b/modules/@angular/core/test/linker/security_integration_spec.ts @@ -15,19 +15,11 @@ const ANCHOR_ELEMENT = /*@ts2dart_const*/ new OpaqueToken('AnchorElement'); export function main() { if (IS_DART) { - declareTests(false); + declareTests({useJit: false}); } else { - describe('jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, true)}]); - declareTests(true); - }); + describe('jit', () => { declareTests({useJit: true}); }); - describe('no jit', () => { - beforeEachProviders( - () => [{provide: CompilerConfig, useValue: new CompilerConfig(true, false, false)}]); - declareTests(false); - }); + describe('no jit', () => { declareTests({useJit: false}); }); } } @@ -52,10 +44,16 @@ function itAsync( } } -function declareTests(isJit: boolean) { +function declareTests({useJit}: {useJit: boolean}) { describe('security integration tests', function() { - beforeEachProviders(() => [{provide: ANCHOR_ELEMENT, useValue: el('
')}]); + beforeEachProviders( + () => + [{ + provide: CompilerConfig, + useValue: new CompilerConfig({genDebugInfo: true, useJit: useJit}) + }, + {provide: ANCHOR_ELEMENT, useValue: el('
')}]); let originalLog: (msg: any) => any; beforeEach(() => { diff --git a/modules/@angular/platform-browser/src/browser.ts b/modules/@angular/platform-browser/src/browser.ts index 4ebffa9ff8..7ad9f39fda 100644 --- a/modules/@angular/platform-browser/src/browser.ts +++ b/modules/@angular/platform-browser/src/browser.ts @@ -63,14 +63,13 @@ export const BROWSER_APP_PROVIDERS: Array = [ Testability, EventManager, ELEMENT_PROBE_PROVIDERS ]; -function _createCompilerConfig() { - return new CompilerConfig( - assertionsEnabled(), false, true, null, null, COMMON_DIRECTIVES, COMMON_PIPES); -} - export const BROWSER_APP_COMPILER_PROVIDERS: Array = [ COMPILER_PROVIDERS, - {provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []}, + { + provide: CompilerConfig, + useValue: + new CompilerConfig({platformDirectives: COMMON_DIRECTIVES, platformPipes: COMMON_PIPES}) + }, {provide: XHR, useClass: XHRImpl}, ]; diff --git a/modules/@angular/platform-browser/src/worker_app.ts b/modules/@angular/platform-browser/src/worker_app.ts index f6ec1af249..0ca39c24cd 100644 --- a/modules/@angular/platform-browser/src/worker_app.ts +++ b/modules/@angular/platform-browser/src/worker_app.ts @@ -45,14 +45,13 @@ export function workerAppPlatform(): PlatformRef { return assertPlatform(WORKER_APP_PLATFORM_MARKER); } -function _createCompilerConfig() { - return new CompilerConfig( - assertionsEnabled(), false, true, null, null, COMMON_DIRECTIVES, COMMON_PIPES); -} - -export const WORKER_APP_COMPILER_PROVIDERS: Array = [ +const WORKER_APP_COMPILER_PROVIDERS: Array = [ COMPILER_PROVIDERS, - {provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []}, + { + provide: CompilerConfig, + useValue: + new CompilerConfig({platformDirectives: COMMON_DIRECTIVES, platformPipes: COMMON_PIPES}) + }, {provide: XHR, useClass: XHRImpl}, ]; diff --git a/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts b/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts index 5bb1670f93..229026c984 100644 --- a/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts +++ b/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts @@ -70,7 +70,7 @@ export function main() { var domRootRenderer = uiInjector.get(DomRootRenderer); workerRenderStore = new RenderStore(); return [ - Serializer, {provide: CompilerConfig, useValue: new CompilerConfig(true, true, false)}, + Serializer, {provide: CompilerConfig, useValue: new CompilerConfig({genDebugInfo: true})}, {provide: RenderStore, useValue: workerRenderStore}, { provide: RootRenderer, useFactory: (workerSerializer: Serializer) => { diff --git a/modules/benchmarks/src/compiler/compiler_benchmark.ts b/modules/benchmarks/src/compiler/compiler_benchmark.ts index 652bca9b10..03560aa9e8 100644 --- a/modules/benchmarks/src/compiler/compiler_benchmark.ts +++ b/modules/benchmarks/src/compiler/compiler_benchmark.ts @@ -29,7 +29,7 @@ function _createBindings(): any[] { }, // Use interpretative mode as Dart does not support JIT and // we want to be able to compare the numbers between JS and Dart - {provide: CompilerConfig, useValue: new CompilerConfig(false, false, false)} + {provide: CompilerConfig, useValue: new CompilerConfig({genDebugInfo: false, useJit: false, logBindingUpdate: false})} ]; } diff --git a/tools/public_api_guard/public_api_spec.ts b/tools/public_api_guard/public_api_spec.ts index 8490b3d600..4d6dc0289c 100644 --- a/tools/public_api_guard/public_api_spec.ts +++ b/tools/public_api_guard/public_api_spec.ts @@ -169,9 +169,7 @@ const CORE = [ 'const AUTO_STYLE:any', 'const PACKAGE_ROOT_URL:any', 'const PLATFORM_COMMON_PROVIDERS:Array', - 'const PLATFORM_DIRECTIVES:OpaqueToken', 'const PLATFORM_INITIALIZER:any', - 'const PLATFORM_PIPES:OpaqueToken', 'ContentChildMetadata', 'ContentChildMetadata.constructor(_selector:Type|string, {read=null}:{read?:any}={})', 'ContentChildMetadataFactory', @@ -1219,10 +1217,12 @@ const COMPILER = [ 'CompileQueryMetadata.selectors:Array', 'CompileQueryMetadata.toJson():{[key:string]:any}', 'CompilerConfig', - 'CompilerConfig.constructor(genDebugInfo:boolean, logBindingUpdate:boolean, useJit:boolean, renderTypes:RenderTypes=null, defaultEncapsulation:ViewEncapsulation=null)', + 'CompilerConfig.constructor({renderTypes=newDefaultRenderTypes(),defaultEncapsulation=ViewEncapsulation.Emulated,genDebugInfo=assertionsEnabled(),logBindingUpdate=assertionsEnabled(),useJit=true,platformDirectives=[],platformPipes=[]}:{renderTypes?:RenderTypes, defaultEncapsulation?:ViewEncapsulation, genDebugInfo?:boolean, logBindingUpdate?:boolean, useJit?:boolean, platformDirectives?:any[], platformPipes?:any[]}={})', 'CompilerConfig.defaultEncapsulation:ViewEncapsulation', 'CompilerConfig.genDebugInfo:boolean', 'CompilerConfig.logBindingUpdate:boolean', + 'CompilerConfig.platformDirectives:any[]', + 'CompilerConfig.platformPipes:any[]', 'CompilerConfig.renderTypes:RenderTypes', 'CompilerConfig.useJit:boolean', 'CompileTemplateMetadata',