refactor(compiler): make PLATFORM_PIPES
/ PLATFORM_DIRECTIVES
an option on CompilerConfig
This aligns the configuration of platform pipes / directives with offline compilation. BREAKING CHANGE: - `PLATFORM_PIPES` and `PLATFORM_DIRECTIVES` now are fields on `CompilerConfig`. Instead of providing a binding to these tokens, provide a binding for `CompilerConfig` instead.
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from '@angular/common';
|
||||
import {COMPILER_PROVIDERS, XHR} from '@angular/compiler';
|
||||
import {APPLICATION_COMMON_PROVIDERS, APP_INITIALIZER, ComponentRef, ExceptionHandler, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_DIRECTIVES, PLATFORM_PIPES, PlatformRef, ReflectiveInjector, RootRenderer, Type, assertPlatform, coreLoadAndBootstrap, createPlatform, getPlatform} from '@angular/core';
|
||||
import {COMPILER_PROVIDERS, CompilerConfig, XHR} from '@angular/compiler';
|
||||
import {APPLICATION_COMMON_PROVIDERS, APP_INITIALIZER, ComponentRef, ExceptionHandler, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PlatformRef, ReflectiveInjector, RootRenderer, Type, assertPlatform, coreLoadAndBootstrap, createPlatform, getPlatform} from '@angular/core';
|
||||
|
||||
import {BROWSER_SANITIZATION_PROVIDERS} from './browser';
|
||||
import {isBlank, isPresent, print} from './facade/lang';
|
||||
import {assertionsEnabled, isBlank, isPresent, print} from './facade/lang';
|
||||
import {ON_WEB_WORKER} from './web_workers/shared/api';
|
||||
import {ClientMessageBrokerFactory, ClientMessageBrokerFactory_} from './web_workers/shared/client_message_broker';
|
||||
import {MessageBus} from './web_workers/shared/message_bus';
|
||||
@ -29,8 +29,6 @@ export const WORKER_APP_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*
|
||||
|
||||
export const WORKER_APP_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
APPLICATION_COMMON_PROVIDERS, FORM_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS, Serializer,
|
||||
{provide: PLATFORM_PIPES, useValue: COMMON_PIPES, multi: true},
|
||||
{provide: PLATFORM_DIRECTIVES, useValue: COMMON_DIRECTIVES, multi: true},
|
||||
{provide: ClientMessageBrokerFactory, useClass: ClientMessageBrokerFactory_},
|
||||
{provide: ServiceMessageBrokerFactory, useClass: ServiceMessageBrokerFactory_},
|
||||
WebWorkerRootRenderer, {provide: RootRenderer, useExisting: WebWorkerRootRenderer},
|
||||
@ -47,12 +45,23 @@ 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<any /*Type | Provider | any[]*/> = [
|
||||
COMPILER_PROVIDERS,
|
||||
{provide: CompilerConfig, useFactory: _createCompilerConfig, deps: []},
|
||||
{provide: XHR, useClass: XHRImpl},
|
||||
];
|
||||
|
||||
export function bootstrapApp(
|
||||
appComponentType: Type,
|
||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
|
||||
var appInjector = ReflectiveInjector.resolveAndCreate(
|
||||
[
|
||||
WORKER_APP_APPLICATION_PROVIDERS, COMPILER_PROVIDERS, {provide: XHR, useClass: XHRImpl},
|
||||
WORKER_APP_APPLICATION_PROVIDERS, WORKER_APP_COMPILER_PROVIDERS,
|
||||
isPresent(customProviders) ? customProviders : []
|
||||
],
|
||||
workerAppPlatform().injector);
|
||||
|
Reference in New Issue
Block a user