From 5a21f168d6ad62a3889854711eea361d9598310b Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Tue, 26 Jul 2016 05:21:19 -0700 Subject: [PATCH] refactor(core): change bootstrap of modules and names of platforms BREAKING CHANGES: - `browserPlatform`/`browserDynamicPlatform`/... have been deprecated and renamed into `platformBrowser`/`platformBrowserDynamic`/.... - `bootstrapModule` and `bootstrapModuleFactory` have been moved to be members of `PlaformRef`. E.g. `platformBrowserDynamic().bootstrapModule(MyModule)`. --- modules/@angular/compiler-cli/README.md | 3 +- .../integrationtest/src/module.ts | 2 +- .../compiler-cli/integrationtest/test/util.ts | 4 +- modules/@angular/compiler/compiler.ts | 2 +- modules/@angular/compiler/src/compiler.ts | 4 +- modules/@angular/compiler/testing.ts | 6 +- modules/@angular/core/index.ts | 2 +- modules/@angular/core/src/application_ref.ts | 140 +++++++++--------- .../core/src/platform_core_providers.ts | 2 +- .../core/test/application_ref_spec.ts | 15 +- modules/@angular/core/testing/test_bed.ts | 2 +- .../examples/core/ts/platform/platform.ts | 8 +- .../platform-browser-dynamic/index.ts | 33 +++-- .../platform-browser-dynamic/testing.ts | 16 +- modules/@angular/platform-browser/index.ts | 2 +- .../@angular/platform-browser/src/browser.ts | 15 +- .../platform-browser/src/worker_app.ts | 13 +- .../platform-browser/src/worker_render.ts | 16 +- .../test/browser/bootstrap_spec.ts | 8 +- .../test/testing_public_spec.ts | 2 +- .../worker/renderer_integration_spec.ts | 4 +- .../platform-browser/testing/browser.ts | 15 +- modules/@angular/platform-server/index.ts | 2 +- .../@angular/platform-server/src/server.ts | 30 ++-- .../platform-server/testing/server.ts | 21 ++- .../@angular/upgrade/src/upgrade_adapter.ts | 10 +- .../web_workers/router/background_index.ts | 5 +- 27 files changed, 219 insertions(+), 163 deletions(-) diff --git a/modules/@angular/compiler-cli/README.md b/modules/@angular/compiler-cli/README.md index 20625353a6..4ce8961962 100644 --- a/modules/@angular/compiler-cli/README.md +++ b/modules/@angular/compiler-cli/README.md @@ -50,10 +50,9 @@ bootstrap.ts ------------- import {MainModuleNgFactory} from './main_module.ngfactory'; -import {bootstrapModuleFactory} from '@angular/core'; import {browserPlatform} from '@angular/platform-browser'; -bootstrapModuleFactory(MainModuleNgFactory, browserPlatform()); +browserPlatform().bootstrapModuleFactory(MainModuleNgFactory); ``` ## Configuration diff --git a/modules/@angular/compiler-cli/integrationtest/src/module.ts b/modules/@angular/compiler-cli/integrationtest/src/module.ts index ad9029a6c5..a4173fa1c0 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/module.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/module.ts @@ -14,7 +14,7 @@ import {AnimateCmp} from './animate'; import {BasicComp} from './basic'; import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from './entry_components'; import {CompWithProviders, CompWithReferences, ModuleUsingCustomElements} from './features'; -import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, someLibModuleWithProviders, SomePipeInRootModule, SomeService} from './module_fixtures'; +import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, SomePipeInRootModule, SomeService, someLibModuleWithProviders} from './module_fixtures'; import {ProjectingComp} from './projection'; import {CompWithChildQuery, CompWithDirectiveChild} from './queries'; diff --git a/modules/@angular/compiler-cli/integrationtest/test/util.ts b/modules/@angular/compiler-cli/integrationtest/test/util.ts index 681dacebd3..765c64156d 100644 --- a/modules/@angular/compiler-cli/integrationtest/test/util.ts +++ b/modules/@angular/compiler-cli/integrationtest/test/util.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgModuleFactory, NgModuleRef, bootstrapModuleFactory} from '@angular/core'; +import {NgModuleFactory, NgModuleRef} from '@angular/core'; import {ComponentFixture} from '@angular/core/testing'; import {serverPlatform} from '@angular/platform-server'; @@ -14,7 +14,7 @@ import {MainModule} from '../src/module'; import {MainModuleNgFactory} from '../src/module.ngfactory'; export function createModule(): NgModuleRef { - return bootstrapModuleFactory(MainModuleNgFactory, serverPlatform()); + return serverPlatform().bootstrapModuleFactory(MainModuleNgFactory); } export function createComponent(comp: {new (...args: any[]): C}): ComponentFixture { diff --git a/modules/@angular/compiler/compiler.ts b/modules/@angular/compiler/compiler.ts index c4eef85043..26e28e7f3b 100644 --- a/modules/@angular/compiler/compiler.ts +++ b/modules/@angular/compiler/compiler.ts @@ -11,7 +11,7 @@ * @description * Starting point to import all compiler APIs. */ -export {COMPILER_PROVIDERS, CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileFactoryMetadata, CompileIdentifierMetadata, CompileMetadataWithIdentifier, CompilePipeMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTemplateMetadata, CompileTokenMetadata, CompileTypeMetadata, CompilerConfig, DEFAULT_PACKAGE_URL_PROVIDER, DirectiveResolver, NgModuleResolver, OfflineCompiler, PipeResolver, RenderTypes, RuntimeCompiler, SourceModule, TEMPLATE_TRANSFORMS, UrlResolver, ViewResolver, XHR, analyzeAppProvidersForDeprecatedConfiguration, coreDynamicPlatform, createOfflineCompileUrlResolver} from './src/compiler'; +export {COMPILER_PROVIDERS, CompileDiDependencyMetadata, CompileDirectiveMetadata, CompileFactoryMetadata, CompileIdentifierMetadata, CompileMetadataWithIdentifier, CompilePipeMetadata, CompileProviderMetadata, CompileQueryMetadata, CompileTemplateMetadata, CompileTokenMetadata, CompileTypeMetadata, CompilerConfig, DEFAULT_PACKAGE_URL_PROVIDER, DirectiveResolver, NgModuleResolver, OfflineCompiler, PipeResolver, RenderTypes, RuntimeCompiler, SourceModule, TEMPLATE_TRANSFORMS, UrlResolver, ViewResolver, XHR, analyzeAppProvidersForDeprecatedConfiguration, createOfflineCompileUrlResolver, platformCoreDynamic} from './src/compiler'; export {ElementSchemaRegistry} from './src/schema/element_schema_registry'; export * from './src/template_ast'; diff --git a/modules/@angular/compiler/src/compiler.ts b/modules/@angular/compiler/src/compiler.ts index 50b83aeb08..6a4da57f60 100644 --- a/modules/@angular/compiler/src/compiler.ts +++ b/modules/@angular/compiler/src/compiler.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Compiler, CompilerFactory, CompilerOptions, Component, ComponentResolver, Inject, Injectable, NgModule, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, PlatformRef, ReflectiveInjector, Type, ViewEncapsulation, corePlatform, createPlatformFactory, disposePlatform, isDevMode} from '@angular/core'; +import {Compiler, CompilerFactory, CompilerOptions, Component, ComponentResolver, Inject, Injectable, NgModule, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, PlatformRef, ReflectiveInjector, Type, ViewEncapsulation, createPlatformFactory, disposePlatform, isDevMode, platformCore} from '@angular/core'; export * from './template_ast'; export {TEMPLATE_TRANSFORMS} from './template_parser'; @@ -199,7 +199,7 @@ function _initReflector() { * * @experimental */ -export const coreDynamicPlatform = createPlatformFactory(corePlatform, 'coreDynamic', [ +export const platformCoreDynamic = createPlatformFactory(platformCore, 'coreDynamic', [ {provide: CompilerOptions, useValue: {}, multi: true}, {provide: CompilerFactory, useClass: RuntimeCompilerFactory}, {provide: PLATFORM_INITIALIZER, useValue: _initReflector, multi: true}, diff --git a/modules/@angular/compiler/testing.ts b/modules/@angular/compiler/testing.ts index 3c1664e08a..24ccc6934c 100644 --- a/modules/@angular/compiler/testing.ts +++ b/modules/@angular/compiler/testing.ts @@ -13,7 +13,7 @@ export * from './testing/directive_resolver_mock'; export * from './testing/ng_module_resolver_mock'; import {createPlatformFactory, CompilerOptions, PlatformRef} from '@angular/core'; -import {coreDynamicPlatform, DirectiveResolver, ViewResolver, NgModuleResolver} from './index'; +import {platformCoreDynamic, DirectiveResolver, ViewResolver, NgModuleResolver} from './index'; import {MockViewResolver} from './testing/view_resolver_mock'; import {MockDirectiveResolver} from './testing/directive_resolver_mock'; import {MockNgModuleResolver} from './testing/ng_module_resolver_mock'; @@ -24,8 +24,8 @@ import {MockNgModuleResolver} from './testing/ng_module_resolver_mock'; * * @experimental */ -export const coreDynamicTestingPlatform = - createPlatformFactory(coreDynamicPlatform, 'coreDynamicTesting', [{ +export const platformCoreDynamicTesting = + createPlatformFactory(platformCoreDynamic, 'coreDynamicTesting', [{ provide: CompilerOptions, useValue: { providers: [ diff --git a/modules/@angular/core/index.ts b/modules/@angular/core/index.ts index 20c0ea3e4e..bf0a3f27a5 100644 --- a/modules/@angular/core/index.ts +++ b/modules/@angular/core/index.ts @@ -14,7 +14,7 @@ export * from './src/metadata'; export * from './src/util'; export * from './src/di'; -export {createPlatform, assertPlatform, disposePlatform, getPlatform, bootstrapModuleFactory, bootstrapModule, coreBootstrap, coreLoadAndBootstrap, PlatformRef, ApplicationRef, enableProdMode, lockRunMode, isDevMode, createPlatformFactory} from './src/application_ref'; +export {createPlatform, assertPlatform, disposePlatform, getPlatform, coreBootstrap, coreLoadAndBootstrap, PlatformRef, ApplicationRef, enableProdMode, lockRunMode, isDevMode, createPlatformFactory} from './src/application_ref'; export {APP_ID, APP_INITIALIZER, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER} from './src/application_tokens'; export * from './src/zone'; export * from './src/render'; diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index f46aaa8e10..ec85d7ad41 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -161,71 +161,6 @@ export function getPlatform(): PlatformRef { return isPresent(_platform) && !_platform.disposed ? _platform : null; } -/** - * Creates an instance of an `@NgModule` for the given platform - * for offline compilation. - * - * ## Simple Example - * - * ```typescript - * my_module.ts: - * - * @NgModule({ - * imports: [BrowserModule] - * }) - * class MyModule {} - * - * main.ts: - * import {MyModuleNgFactory} from './my_module.ngfactory'; - * import {bootstrapModuleFactory} from '@angular/core'; - * import {browserPlatform} from '@angular/platform-browser'; - * - * let moduleRef = bootstrapModuleFactory(MyModuleNgFactory, browserPlatform()); - * ``` - * - * @experimental APIs related to application bootstrap are currently under review. - */ -export function bootstrapModuleFactory( - moduleFactory: NgModuleFactory, platform: PlatformRef): NgModuleRef { - // Note: We need to create the NgZone _before_ we instantiate the module, - // as instantiating the module creates some providers eagerly. - // So we create a mini parent injector that just contains the new NgZone and - // pass that as parent to the NgModuleFactory. - const ngZone = new NgZone({enableLongStackTrace: isDevMode()}); - const ngZoneInjector = - ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], platform.injector); - return ngZone.run(() => moduleFactory.create(ngZoneInjector)); -} - -/** - * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler. - * - * ## Simple Example - * - * ```typescript - * @NgModule({ - * imports: [BrowserModule] - * }) - * class MyModule {} - * - * let moduleRef = bootstrapModule(MyModule, browserPlatform()); - * ``` - * @stable - */ -export function bootstrapModule( - moduleType: ConcreteType, platform: PlatformRef, - compilerOptions: CompilerOptions | CompilerOptions[] = []): Promise> { - const compilerFactory: CompilerFactory = platform.injector.get(CompilerFactory); - const compiler = compilerFactory.createCompiler( - compilerOptions instanceof Array ? compilerOptions : [compilerOptions]); - return compiler.compileModuleAsync(moduleType) - .then((moduleFactory) => bootstrapModuleFactory(moduleFactory, platform)) - .then((moduleRef) => { - const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef); - return appRef.waitForAsyncInitializers().then(() => moduleRef); - }); -} - /** * Shortcut for ApplicationRef.bootstrap. * Requires a platform to be created first. @@ -261,8 +196,56 @@ export function coreLoadAndBootstrap( */ export abstract class PlatformRef { /** - * Register a listener to be called when the platform is disposed. + * Creates an instance of an `@NgModule` for the given platform + * for offline compilation. + * + * ## Simple Example + * + * ```typescript + * my_module.ts: + * + * @NgModule({ + * imports: [BrowserModule] + * }) + * class MyModule {} + * + * main.ts: + * import {MyModuleNgFactory} from './my_module.ngfactory'; + * import {browserPlatform} from '@angular/platform-browser'; + * + * let moduleRef = browserPlatform().bootstrapModuleFactory(MyModuleNgFactory); + * ``` + * + * @experimental APIs related to application bootstrap are currently under review. */ + bootstrapModuleFactory(moduleFactory: NgModuleFactory): NgModuleRef { + throw unimplemented(); + } + + /** + * Creates an instance of an `@NgModule` for a given platform using the given runtime compiler. + * + * ## Simple Example + * + * ```typescript + * @NgModule({ + * imports: [BrowserModule] + * }) + * class MyModule {} + * + * let moduleRef = browserPlatform().bootstrapModule(MyModule); + * ``` + * @stable + */ + bootstrapModule( + moduleType: ConcreteType, + compilerOptions: CompilerOptions|CompilerOptions[] = []): Promise> { + throw unimplemented(); + } + + /** +*Register a listener to be called when the platform is disposed. +*/ abstract registerDisposeListener(dispose: () => void): void; /** @@ -313,6 +296,31 @@ export class PlatformRef_ extends PlatformRef { /** @internal */ _applicationDisposed(app: ApplicationRef): void { ListWrapper.remove(this._applications, app); } + + bootstrapModuleFactory(moduleFactory: NgModuleFactory): NgModuleRef { + // Note: We need to create the NgZone _before_ we instantiate the module, + // as instantiating the module creates some providers eagerly. + // So we create a mini parent injector that just contains the new NgZone and + // pass that as parent to the NgModuleFactory. + const ngZone = new NgZone({enableLongStackTrace: isDevMode()}); + const ngZoneInjector = + ReflectiveInjector.resolveAndCreate([{provide: NgZone, useValue: ngZone}], this.injector); + return ngZone.run(() => moduleFactory.create(ngZoneInjector)); + } + + bootstrapModule( + moduleType: ConcreteType, + compilerOptions: CompilerOptions|CompilerOptions[] = []): Promise> { + const compilerFactory: CompilerFactory = this.injector.get(CompilerFactory); + const compiler = compilerFactory.createCompiler( + compilerOptions instanceof Array ? compilerOptions : [compilerOptions]); + return compiler.compileModuleAsync(moduleType) + .then((moduleFactory) => this.bootstrapModuleFactory(moduleFactory)) + .then((moduleRef) => { + const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef); + return appRef.waitForAsyncInitializers().then(() => moduleRef); + }); + } } /** diff --git a/modules/@angular/core/src/platform_core_providers.ts b/modules/@angular/core/src/platform_core_providers.ts index 4d01845e7f..0ee30dad2f 100644 --- a/modules/@angular/core/src/platform_core_providers.ts +++ b/modules/@angular/core/src/platform_core_providers.ts @@ -32,7 +32,7 @@ const _CORE_PLATFORM_PROVIDERS: Array = [ * * @experimental */ -export const corePlatform = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS); +export const platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS); /** * A default set of providers which should be included in any Angular platform. diff --git a/modules/@angular/core/test/application_ref_spec.ts b/modules/@angular/core/test/application_ref_spec.ts index d359ae91c3..38f416a099 100644 --- a/modules/@angular/core/test/application_ref_spec.ts +++ b/modules/@angular/core/test/application_ref_spec.ts @@ -10,8 +10,8 @@ import {AsyncTestCompleter, ddescribe, describe, it, iit, xit, expect, beforeEac import {SpyChangeDetectorRef} from './spies'; import {ConcreteType} from '../src/facade/lang'; import {ApplicationRef_, ApplicationRef} from '@angular/core/src/application_ref'; -import {Type, NgModule, CompilerFactory, Injector, APP_INITIALIZER, Component, ReflectiveInjector, bootstrapModule, bootstrapModuleFactory, PlatformRef, disposePlatform, createPlatformFactory, ComponentResolver, ComponentFactoryResolver, ChangeDetectorRef, ApplicationModule} from '@angular/core'; -import {coreDynamicPlatform} from '@angular/compiler'; +import {Type, NgModule, CompilerFactory, Injector, APP_INITIALIZER, Component, ReflectiveInjector, PlatformRef, disposePlatform, createPlatformFactory, ComponentResolver, ComponentFactoryResolver, ChangeDetectorRef, ApplicationModule} from '@angular/core'; +import {platformCoreDynamic} from '@angular/compiler'; import {Console} from '@angular/core/src/console'; import {BaseException} from '../src/facade/exceptions'; import {PromiseWrapper, PromiseCompleter, TimerWrapper} from '../src/facade/async'; @@ -28,7 +28,7 @@ export function main() { beforeEach(() => { errorLogger = new _ArrayLogger(); disposePlatform(); - defaultPlatform = createPlatformFactory(coreDynamicPlatform, 'test')(); + defaultPlatform = createPlatformFactory(platformCoreDynamic, 'test')(); someCompFactory = new _MockComponentFactory(new _MockComponentRef(ReflectiveInjector.resolveAndCreate([]))); appProviders = [ @@ -53,7 +53,7 @@ export function main() { const compilerFactory: CompilerFactory = platform.injector.get(CompilerFactory); const compiler = compilerFactory.createCompiler(); const appInjector = - bootstrapModuleFactory(compiler.compileModuleSync(createModule(providers)), platform) + platform.bootstrapModuleFactory(compiler.compileModuleSync(createModule(providers))) .injector; return appInjector.get(ApplicationRef); } @@ -100,10 +100,9 @@ export function main() { initializerDone = true; }, 1); - bootstrapModule( - createModule( - [{provide: APP_INITIALIZER, useValue: () => completer.promise, multi: true}]), - defaultPlatform) + defaultPlatform + .bootstrapModule(createModule( + [{provide: APP_INITIALIZER, useValue: () => completer.promise, multi: true}])) .then(_ => { expect(initializerDone).toBe(true); async.done(); diff --git a/modules/@angular/core/testing/test_bed.ts b/modules/@angular/core/testing/test_bed.ts index 824a900c35..174ad02fd9 100644 --- a/modules/@angular/core/testing/test_bed.ts +++ b/modules/@angular/core/testing/test_bed.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Compiler, SchemaMetadata, CompilerFactory, CompilerOptions, ComponentStillLoadingError, Injector, NgModule, NgModuleFactory, NgModuleMetadata, NgModuleRef, PlatformRef, Provider, ReflectiveInjector, Type, assertPlatform, createPlatform, getPlatform} from '../index'; +import {Compiler, CompilerFactory, CompilerOptions, ComponentStillLoadingError, Injector, NgModule, NgModuleFactory, NgModuleMetadata, NgModuleRef, PlatformRef, Provider, ReflectiveInjector, SchemaMetadata, Type, assertPlatform, createPlatform, getPlatform} from '../index'; import {ListWrapper} from '../src/facade/collection'; import {BaseException} from '../src/facade/exceptions'; import {ConcreteType, FunctionWrapper, isPresent, stringify} from '../src/facade/lang'; diff --git a/modules/@angular/examples/core/ts/platform/platform.ts b/modules/@angular/examples/core/ts/platform/platform.ts index 8b9fd2b4c0..842bbbef87 100644 --- a/modules/@angular/examples/core/ts/platform/platform.ts +++ b/modules/@angular/examples/core/ts/platform/platform.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {Component, ReflectiveInjector, bootstrapModule, createPlatformFactory} from '@angular/core'; +import {Component, ReflectiveInjector, createPlatformFactory} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; -import {browserDynamicPlatform} from '@angular/platform-browser-dynamic'; +import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; var appProviders: any[] = []; @@ -17,6 +17,6 @@ var appProviders: any[] = []; class MyApp { } -var myPlatformFactory = createPlatformFactory(browserDynamicPlatform, 'myPlatform'); -bootstrapModule(MyApp, myPlatformFactory()); +var myPlatformFactory = createPlatformFactory(platformBrowserDynamic, 'myPlatform'); +myPlatformFactory().bootstrapModule(MyApp); // #enddocregion diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index b35fecff04..65c0287dcf 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {XHR, analyzeAppProvidersForDeprecatedConfiguration, coreDynamicPlatform} from '@angular/compiler'; -import {SchemaMetadata, ApplicationRef, Compiler, CompilerFactory, CompilerOptions, ComponentRef, ComponentResolver, ExceptionHandler, NgModule, NgModuleRef, OpaqueToken, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, PlatformRef, ReflectiveInjector, Type, assertPlatform, bootstrapModule, bootstrapModuleFactory, createPlatform, createPlatformFactory, getPlatform, isDevMode} from '@angular/core'; -import {BROWSER_PLATFORM_PROVIDERS, BrowserModule, WORKER_APP_PLATFORM_PROVIDERS, WORKER_SCRIPT, WorkerAppModule, browserPlatform, workerAppPlatform, workerUiPlatform} from '@angular/platform-browser'; +import {XHR, analyzeAppProvidersForDeprecatedConfiguration, platformCoreDynamic} from '@angular/compiler'; +import {ApplicationRef, Compiler, CompilerFactory, CompilerOptions, ComponentRef, ComponentResolver, ExceptionHandler, NgModule, NgModuleRef, OpaqueToken, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, PlatformRef, ReflectiveInjector, SchemaMetadata, Type, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode} from '@angular/core'; +import {BROWSER_PLATFORM_PROVIDERS, BrowserModule, WORKER_APP_PLATFORM_PROVIDERS, WORKER_SCRIPT, WorkerAppModule, platformBrowser, platformWorkerApp, platformWorkerUi} from '@angular/platform-browser'; import {Console} from './core_private'; import {PromiseWrapper} from './src/facade/async'; @@ -34,8 +34,13 @@ export const CACHED_TEMPLATE_PROVIDER: Array = /** * @experimental API related to bootstrapping are still under review. */ -export const browserDynamicPlatform = createPlatformFactory( - coreDynamicPlatform, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS); +export const platformBrowserDynamic = createPlatformFactory( + platformCoreDynamic, 'browserDynamic', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS); + +/** + * @deprecated Use {@link platformBrowserDynamic} instead + */ +export const browserDynamicPlatform = platformBrowserDynamic; /** * Bootstrapping for Angular applications. @@ -170,7 +175,8 @@ export function bootstrap( class DynamicModule { } - return bootstrapModule(DynamicModule, browserDynamicPlatform(), compilerOptions) + return platformBrowserDynamic() + .bootstrapModule(DynamicModule, compilerOptions) .then((moduleRef) => { const console = moduleRef.injector.get(Console); deprecationMessages.forEach((msg) => console.warn(msg)); @@ -188,7 +194,7 @@ export function bootstrapWorkerUi( workerScriptUri: string, customProviders: Array = []): Promise { // For now, just creates the worker ui platform... - return Promise.resolve(workerUiPlatform([{ + return Promise.resolve(platformWorkerUi([{ provide: WORKER_SCRIPT, useValue: workerScriptUri, }].concat(customProviders))); @@ -197,13 +203,18 @@ export function bootstrapWorkerUi( /** * @experimental API related to bootstrapping are still under review. */ -export const workerAppDynamicPlatform = - createPlatformFactory(coreDynamicPlatform, 'workerAppDynamic', [{ +export const platformWorkerAppDynamic = + createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [{ provide: CompilerOptions, useValue: {providers: [{provide: XHR, useClass: XHRImpl}]}, multi: true }]); +/** + * @deprecated Use {@link platformWorkerAppDynamic} instead + */ +export const workerAppDynamicPlatform = platformWorkerAppDynamic; + /** * @deprecated Create an {@link NgModule} that includes the {@link WorkerAppModule} and use {@link * bootstrapModule} @@ -227,8 +238,8 @@ export function bootstrapWorkerApp( class DynamicModule { } - return bootstrapModule( - DynamicModule, workerAppDynamicPlatform(), deprecatedConfiguration.compilerOptions) + return platformWorkerAppDynamic() + .bootstrapModule(DynamicModule, deprecatedConfiguration.compilerOptions) .then((moduleRef) => { const console = moduleRef.injector.get(Console); deprecatedConfiguration.deprecationMessages.forEach((msg) => console.warn(msg)); diff --git a/modules/@angular/platform-browser-dynamic/testing.ts b/modules/@angular/platform-browser-dynamic/testing.ts index 22f164a926..b373f87d65 100644 --- a/modules/@angular/platform-browser-dynamic/testing.ts +++ b/modules/@angular/platform-browser-dynamic/testing.ts @@ -7,13 +7,12 @@ */ import {CompilerConfig, DirectiveResolver, NgModuleResolver, ViewResolver, analyzeAppProvidersForDeprecatedConfiguration} from '@angular/compiler'; -import {OverridingTestComponentBuilder, coreDynamicTestingPlatform} from '@angular/compiler/testing'; +import {OverridingTestComponentBuilder, platformCoreDynamicTesting} from '@angular/compiler/testing'; import {Compiler, CompilerFactory, CompilerOptions, NgModule, PlatformRef, Provider, ReflectiveInjector, Type, createPlatform, createPlatformFactory} from '@angular/core'; import {TestComponentBuilder, TestComponentRenderer, initTestEnvironment} from '@angular/core/testing'; -import {BrowserTestingModule, browserTestingPlatform} from '@angular/platform-browser/testing'; +import {BrowserTestingModule, platformBrowserTesting} from '@angular/platform-browser/testing'; import {Console} from './core_private'; -import {browserDynamicPlatform} from './index'; import {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './src/platform_providers'; import {DOMTestComponentRenderer} from './testing/dom_test_component_renderer'; @@ -22,10 +21,15 @@ export * from './private_export_testing' /** * @experimental API related to bootstrapping are still under review. */ -export const browserDynamicTestingPlatform = createPlatformFactory( - coreDynamicTestingPlatform, 'browserDynamicTesting', +export const platformBrowserDynamicTesting = createPlatformFactory( + platformCoreDynamicTesting, 'browserDynamicTesting', INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS); +/** + * @deprecated Use {@link platformBrowserDynamicTesting} instead + */ +export const browserDynamicTestingPlatform = platformBrowserDynamicTesting; + /** * NgModule for testing. * @@ -50,7 +54,7 @@ export const TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS: Array { const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(appProviders); const platformRef = - createPlatformFactory(browserDynamicTestingPlatform, 'browserDynamicTestingDeprecated', [{ + createPlatformFactory(platformBrowserDynamicTesting, 'browserDynamicTestingDeprecated', [{ provide: CompilerOptions, useValue: deprecatedConfiguration.compilerOptions, multi: true diff --git a/modules/@angular/platform-browser/index.ts b/modules/@angular/platform-browser/index.ts index 7c54b8ef63..7fc895c3d0 100644 --- a/modules/@angular/platform-browser/index.ts +++ b/modules/@angular/platform-browser/index.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -export {BROWSER_APP_PROVIDERS, BROWSER_PLATFORM_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS, BrowserModule, browserPlatform} from './src/browser'; +export {BROWSER_APP_PROVIDERS, BROWSER_PLATFORM_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS, BrowserModule, platformBrowser} from './src/browser'; export {BrowserPlatformLocation} from './src/browser/location/browser_platform_location'; export {Title} from './src/browser/title'; export {disableDebugTools, enableDebugTools} from './src/browser/tools/tools'; diff --git a/modules/@angular/platform-browser/src/browser.ts b/modules/@angular/platform-browser/src/browser.ts index 561dd4ea3e..1f2b03f40d 100644 --- a/modules/@angular/platform-browser/src/browser.ts +++ b/modules/@angular/platform-browser/src/browser.ts @@ -7,7 +7,7 @@ */ import {CommonModule, PlatformLocation} from '@angular/common'; -import {ApplicationModule, ExceptionHandler, NgModule, NgModuleFactory, NgModuleRef, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, SanitizationService, Testability, assertPlatform, corePlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode} from '@angular/core'; +import {ApplicationModule, ExceptionHandler, NgModule, NgModuleFactory, NgModuleRef, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, RootRenderer, SanitizationService, Testability, assertPlatform, createPlatform, createPlatformFactory, getPlatform, isDevMode, platformCore} from '@angular/core'; import {wtfInit} from '../core_private'; import {AnimationDriver} from '../src/dom/animation_driver'; @@ -38,8 +38,8 @@ export const INTERNAL_BROWSER_PLATFORM_PROVIDERS: Array = [PLATFORM_COMMON_PROVIDERS, INTERNAL_BROWSER_PLATFORM_PROVIDERS]; @@ -71,8 +71,13 @@ export const BROWSER_APP_PROVIDERS: Array = []; /** * @experimental API related to bootstrapping are still under review. */ -export const browserPlatform = - createPlatformFactory(corePlatform, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS); +export const platformBrowser = + createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS); + +/** + * @deprecated Use {@link platformBrowser} instead + */ +export const browserPlatform = platformBrowser; export function initDomAdapter() { BrowserDomAdapter.makeCurrent(); diff --git a/modules/@angular/platform-browser/src/worker_app.ts b/modules/@angular/platform-browser/src/worker_app.ts index 537c9f22bb..01ed097201 100644 --- a/modules/@angular/platform-browser/src/worker_app.ts +++ b/modules/@angular/platform-browser/src/worker_app.ts @@ -7,7 +7,7 @@ */ import {CommonModule, FORM_PROVIDERS} from '@angular/common'; -import {APP_INITIALIZER, ApplicationModule, ExceptionHandler, NgModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, corePlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core'; +import {APP_INITIALIZER, ApplicationModule, ExceptionHandler, NgModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PlatformRef, ReflectiveInjector, RootRenderer, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core'; import {BROWSER_SANITIZATION_PROVIDERS} from './browser'; import {isBlank, print} from './facade/lang'; @@ -29,8 +29,8 @@ class PrintLogger { } /** - * @deprecated Use `workerAppPlatform()` or create a custom platform factory via - * `createPlatformFactory(workerAppPlatform, ...)` + * @deprecated Use `platformWorkerApp()` or create a custom platform factory via + * `createPlatformFactory(platformWorkerApp, ...)` */ export const WORKER_APP_PLATFORM_PROVIDERS: Array = PLATFORM_COMMON_PROVIDERS; @@ -46,7 +46,12 @@ export const WORKER_APP_APPLICATION_PROVIDERS: Array = [PLATFORM_COMMON_PROVIDERS, _WORKER_UI_PLATFORM_PROVIDERS]; @@ -155,8 +155,14 @@ function initWebWorkerRenderPlatform(injector: Injector): () => void { /** * @experimental WebWorker support is currently experimental. */ -export const workerUiPlatform = - createPlatformFactory(corePlatform, 'workerUi', _WORKER_UI_PLATFORM_PROVIDERS); +export const platformWorkerUi = + createPlatformFactory(platformCore, 'workerUi', _WORKER_UI_PLATFORM_PROVIDERS); + +/** + * @deprecated Use {@link platformWorkerUi} instead + */ +export const workerUiPlatform = platformWorkerUi; + function _exceptionHandler(): ExceptionHandler { return new ExceptionHandler(getDOM()); diff --git a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts index 56f721f887..733475d3d6 100644 --- a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts +++ b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts @@ -8,7 +8,7 @@ import {LowerCasePipe, NgIf} from '@angular/common'; import {XHR} from '@angular/compiler'; -import {APP_INITIALIZER, createPlatformFactory, CUSTOM_ELEMENTS_SCHEMA, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, Pipe, ReflectiveInjector, bootstrapModule, createPlatform, provide} from '@angular/core'; +import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Component, Directive, ExceptionHandler, Inject, Input, NgModule, OnDestroy, PLATFORM_DIRECTIVES, PLATFORM_INITIALIZER, PLATFORM_PIPES, Pipe, ReflectiveInjector, createPlatform, createPlatformFactory, provide} from '@angular/core'; import {ApplicationRef, disposePlatform} from '@angular/core/src/application_ref'; import {Console} from '@angular/core/src/console'; import {ComponentRef} from '@angular/core/src/linker/component_factory'; @@ -16,7 +16,7 @@ import {Testability, TestabilityRegistry} from '@angular/core/src/testability/te import {ComponentFixture} from '@angular/core/testing'; import {AsyncTestCompleter, Log, afterEach, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it} from '@angular/core/testing/testing_internal'; import {BrowserModule} from '@angular/platform-browser'; -import {bootstrap, browserDynamicPlatform} from '@angular/platform-browser-dynamic'; +import {bootstrap, platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {DOCUMENT} from '@angular/platform-browser/src/dom/dom_tokens'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -258,7 +258,7 @@ export function main() { it('should run platform initializers', inject([Log, AsyncTestCompleter], (log: Log, async: AsyncTestCompleter) => { - let p = createPlatformFactory(browserDynamicPlatform, 'someName', [ + let p = createPlatformFactory(platformBrowserDynamic, 'someName', [ {provide: PLATFORM_INITIALIZER, useValue: log.fn('platform_init1'), multi: true}, {provide: PLATFORM_INITIALIZER, useValue: log.fn('platform_init2'), multi: true} ])(); @@ -275,7 +275,7 @@ export function main() { expect(log.result()).toEqual('platform_init1; platform_init2'); log.clear(); - bootstrapModule(SomeModule, p).then(() => { + p.bootstrapModule(SomeModule).then(() => { expect(log.result()).toEqual('app_init1; app_init2'); async.done(); }); diff --git a/modules/@angular/platform-browser/test/testing_public_spec.ts b/modules/@angular/platform-browser/test/testing_public_spec.ts index 7f2b41b9ec..88ebe22abb 100644 --- a/modules/@angular/platform-browser/test/testing_public_spec.ts +++ b/modules/@angular/platform-browser/test/testing_public_spec.ts @@ -285,7 +285,7 @@ export function main() { class ComponentUsingInvalidProperty { } - tcb.createSync(ComponentUsingInvalidProperty) + tcb.createSync(ComponentUsingInvalidProperty); expect(() => tcb.createSync(ComponentUsingInvalidProperty)).not.toThrow(); })); }); 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 c8b393389f..d967f5354d 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 @@ -24,7 +24,7 @@ import {createPairedMessageBuses, PairedMessageBuses} from '../shared/web_worker import {ServiceMessageBrokerFactory_} from '@angular/platform-browser/src/web_workers/shared/service_message_broker'; import {dispatchEvent} from '../../../../platform-browser/testing/browser_util'; import {BrowserTestingModule} from '@angular/platform-browser/testing'; -import {browserDynamicTestingPlatform} from '@angular/platform-browser-dynamic/testing'; +import {platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; export function main() { function createWebWorkerBrokerFactory( @@ -65,7 +65,7 @@ export function main() { beforeEach(() => { uiRenderStore = new RenderStore(); var testUiInjector = new TestBed(); - testUiInjector.platform = browserDynamicTestingPlatform(); + testUiInjector.platform = platformBrowserDynamicTesting(); testUiInjector.ngModule = BrowserTestingModule; testUiInjector.configureModule({ providers: [ diff --git a/modules/@angular/platform-browser/testing/browser.ts b/modules/@angular/platform-browser/testing/browser.ts index 659d637e4f..8fdfdceb40 100644 --- a/modules/@angular/platform-browser/testing/browser.ts +++ b/modules/@angular/platform-browser/testing/browser.ts @@ -7,7 +7,7 @@ */ import {LocationStrategy} from '@angular/common'; -import {APP_ID, NgModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, corePlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core'; +import {APP_ID, NgModule, NgZone, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, createPlatformFactory, getPlatform, platformCore} from '@angular/core'; import {BrowserModule} from '../src/browser'; import {BrowserDomAdapter} from '../src/browser/browser_adapter'; @@ -31,8 +31,8 @@ const _TEST_BROWSER_PLATFORM_PROVIDERS: Array = /** * Providers for the browser test platform * - * @deprecated Use `browserTestingPlatform()` or create a custom platform factory via - * `createPlatformFactory(browserTestingPlatform, ...)` + * @deprecated Use `platformBrowserTesting()` or create a custom platform factory via + * `createPlatformFactory(platformBrowserTesting, ...)` */ export const TEST_BROWSER_PLATFORM_PROVIDERS: Array = [PLATFORM_COMMON_PROVIDERS, _TEST_BROWSER_PLATFORM_PROVIDERS]; @@ -50,8 +50,13 @@ export const TEST_BROWSER_APPLICATION_PROVIDERS: Array = [PLATFORM_COMMON_PROVIDERS, INTERNAL_SERVER_PLATFORM_PROVIDERS]; @@ -57,16 +57,26 @@ function initParse5Adapter() { /** * @experimental */ -export const serverPlatform = - createPlatformFactory(corePlatform, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS); +export const platformServer = + createPlatformFactory(platformCore, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS); + +/** + * @deprecated Use {@link platformServer} instead + */ +export const serverPlatform = platformServer; /** * The server platform that supports the runtime compiler. * * @experimental */ -export const serverDynamicPlatform = - createPlatformFactory(coreDynamicPlatform, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS); +export const platformDynamicServer = + createPlatformFactory(platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS); + +/** + * @deprecated Use {@link platformDynamicServer} instead + */ +export const serverDynamicPlatform = platformDynamicServer; /** * Used to bootstrap Angular in server environment (such as node). @@ -105,8 +115,8 @@ export function serverBootstrap( class DynamicModule { } - return bootstrapModule( - DynamicModule, serverDynamicPlatform(), deprecatedConfiguration.compilerOptions) + return platformDynamicServer() + .bootstrapModule(DynamicModule, deprecatedConfiguration.compilerOptions) .then((moduleRef) => { const console = moduleRef.injector.get(Console); deprecatedConfiguration.deprecationMessages.forEach((msg) => console.warn(msg)); diff --git a/modules/@angular/platform-server/testing/server.ts b/modules/@angular/platform-server/testing/server.ts index dfd3ccd81d..79cad85720 100644 --- a/modules/@angular/platform-server/testing/server.ts +++ b/modules/@angular/platform-server/testing/server.ts @@ -7,13 +7,13 @@ */ import {analyzeAppProvidersForDeprecatedConfiguration} from '@angular/compiler'; -import {coreDynamicTestingPlatform} from '@angular/compiler/testing'; +import {platformCoreDynamicTesting} from '@angular/compiler/testing'; import {CompilerFactory, CompilerOptions, NgModule, OpaqueToken, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, ReflectiveInjector, assertPlatform, createPlatform, createPlatformFactory, getPlatform} from '@angular/core'; import {initTestEnvironment} from '@angular/core/testing'; -import {BrowserDynamicTestingModule, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS, browserDynamicTestingPlatform} from '@angular/platform-browser-dynamic/testing'; +import {BrowserDynamicTestingModule, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; import {Console} from '../core_private'; -import {serverPlatform} from '../index'; +import {platformServer} from '../index'; import {Parse5DomAdapter} from '../src/parse5_adapter'; import {INTERNAL_SERVER_PLATFORM_PROVIDERS} from '../src/server'; @@ -22,8 +22,13 @@ import {INTERNAL_SERVER_PLATFORM_PROVIDERS} from '../src/server'; * * @experimental API related to bootstrapping are still under review. */ -export const serverTestingPlatform = createPlatformFactory( - coreDynamicTestingPlatform, 'serverTesting', INTERNAL_SERVER_PLATFORM_PROVIDERS); +export const platformServerTesting = createPlatformFactory( + platformCoreDynamicTesting, 'serverTesting', INTERNAL_SERVER_PLATFORM_PROVIDERS); + +/** + * @deprecated Use {@link platformServerTesting} instead + */ +export const serverTestingPlatform = platformServerTesting; /** * NgModule for testing. @@ -37,15 +42,15 @@ export class ServerTestingModule { /** * Providers of the `serverTestingPlatform` to be used for creating own platform based on this. * - * @deprecated Use `serverTestingPlatform()` or create a custom platform factory via - * `createPlatformFactory(serverTestingPlatform, ...)` + * @deprecated Use `platformServerTesting()` or create a custom platform factory via + * `createPlatformFactory(platformServerTesting, ...)` */ export const TEST_SERVER_PLATFORM_PROVIDERS: Array = // Note: This is not a real provider but a hack to still support the deprecated // `setBaseTestProviders` method! [(appProviders: any[]) => { const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(appProviders); - const platformRef = createPlatformFactory(serverTestingPlatform, 'serverTestingDeprecated', [{ + const platformRef = createPlatformFactory(platformServerTesting, 'serverTestingDeprecated', [{ provide: CompilerOptions, useValue: deprecatedConfiguration.compilerOptions, multi: true diff --git a/modules/@angular/upgrade/src/upgrade_adapter.ts b/modules/@angular/upgrade/src/upgrade_adapter.ts index 5997c24852..35982ef32a 100644 --- a/modules/@angular/upgrade/src/upgrade_adapter.ts +++ b/modules/@angular/upgrade/src/upgrade_adapter.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {ApplicationRef, Compiler, CompilerFactory, ComponentFactory, ComponentResolver, Injector, NgModule, NgZone, PlatformRef, Provider, ReflectiveInjector, Testability, Type, bootstrapModuleFactory, provide} from '@angular/core'; +import {ApplicationRef, Compiler, CompilerFactory, ComponentFactory, ComponentResolver, Injector, NgModule, NgZone, PlatformRef, Provider, ReflectiveInjector, Testability, Type, provide} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; -import {browserDynamicPlatform} from '@angular/platform-browser-dynamic'; +import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import * as angular from './angular_js'; import {NG1_COMPILE, NG1_INJECTOR, NG1_PARSE, NG1_ROOT_SCOPE, NG1_TESTABILITY, NG2_COMPILER, NG2_COMPONENT_FACTORY_REF_MAP, NG2_INJECTOR, NG2_ZONE, REQUIRE_INJECTOR} from './constants'; @@ -278,7 +278,7 @@ export class UpgradeAdapter { UpgradeAdapterRef { var upgrade = new UpgradeAdapterRef(); var ng1Injector: angular.IInjectorService = null; - var platformRef: PlatformRef = browserDynamicPlatform(); + var platformRef: PlatformRef = platformBrowserDynamic(); var providers = [ {provide: NG1_INJECTOR, useFactory: () => ng1Injector}, {provide: NG1_COMPILE, useFactory: () => ng1Injector.get(NG1_COMPILE)}, this.providers @@ -289,8 +289,8 @@ export class UpgradeAdapter { } const compilerFactory: CompilerFactory = platformRef.injector.get(CompilerFactory); - var moduleRef = bootstrapModuleFactory( - compilerFactory.createCompiler().compileModuleSync(DynamicModule), platformRef); + var moduleRef = platformRef.bootstrapModuleFactory( + compilerFactory.createCompiler().compileModuleSync(DynamicModule)); const boundCompiler: Compiler = moduleRef.injector.get(Compiler); var applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef); var injector: Injector = applicationRef.injector; diff --git a/modules/playground/src/web_workers/router/background_index.ts b/modules/playground/src/web_workers/router/background_index.ts index dc47e0135d..a7616d67fe 100644 --- a/modules/playground/src/web_workers/router/background_index.ts +++ b/modules/playground/src/web_workers/router/background_index.ts @@ -6,11 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {workerAppDynamicPlatform} from '@angular/platform-browser-dynamic'; -import {bootstrapModule} from '@angular/core'; +import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {AppModule} from './index_common'; export function main() { - bootstrapModule(AppModule, workerAppDynamicPlatform()); + platformWorkerAppDynamic().bootstrapModule(AppModule); }