diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index c45cc88f92..9195fbbca1 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -7,7 +7,7 @@ */ import {XHR, analyzeAppProvidersForDeprecatedConfiguration, platformCoreDynamic} from '@angular/compiler'; -import {ApplicationRef, COMPILER_OPTIONS, 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 {ApplicationRef, COMPILER_OPTIONS, CUSTOM_ELEMENTS_SCHEMA, 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'; @@ -116,61 +116,29 @@ export const browserDynamicPlatform = platformBrowserDynamic; * * Returns a `Promise` of {@link ComponentRef}. * - * @experimental This api cannot be used with the offline compiler and thus is still subject to - * change. + * @deprecated This api cannot be used with the offline compiler. Use + * `PlatformRef.boostrapModule()` instead. */ // Note: We are using typescript overloads here to have 2 function signatures! export function bootstrap( appComponentType: ConcreteType, - customProviders?: Array): Promise>; -export function bootstrap( - appComponentType: ConcreteType, - {providers, imports, declarations, entryComponents, schemas, compilerOptions}?: { - providers?: Array, - declarations?: any[], - imports?: any[], - entryComponents?: any[], - schemas?: Array, - compilerOptions?: CompilerOptions - }): Promise>; -export function bootstrap( - appComponentType: ConcreteType, - customProvidersOrDynamicModule?: Array| { - providers: Array, - declarations?: any[], - imports: any[], - entryComponents: any[], schemas?: Array, - compilerOptions: CompilerOptions - }): Promise> { + customProviders?: Array): Promise> { let compilerOptions: CompilerOptions; - let providers: any[] = []; let declarations: any[] = []; - let imports: any[] = []; let entryComponents: any[] = []; let deprecationMessages: string[] = []; - let schemas: any[] = []; - if (customProvidersOrDynamicModule instanceof Array) { - providers = customProvidersOrDynamicModule; - const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(providers); - declarations = deprecatedConfiguration.moduleDeclarations.concat(declarations); - compilerOptions = deprecatedConfiguration.compilerOptions; - deprecationMessages = deprecatedConfiguration.deprecationMessages; - } else if (customProvidersOrDynamicModule) { - providers = normalizeArray(customProvidersOrDynamicModule.providers); - declarations = normalizeArray(customProvidersOrDynamicModule.declarations); - imports = normalizeArray(customProvidersOrDynamicModule.imports); - entryComponents = normalizeArray(customProvidersOrDynamicModule.entryComponents); - schemas = normalizeArray(customProvidersOrDynamicModule.schemas); - compilerOptions = customProvidersOrDynamicModule.compilerOptions; - } + const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(customProviders); + declarations = deprecatedConfiguration.moduleDeclarations.concat(declarations); + compilerOptions = deprecatedConfiguration.compilerOptions; + deprecationMessages = deprecatedConfiguration.deprecationMessages; @NgModule({ - providers: providers, + providers: customProviders, declarations: declarations.concat([appComponentType]), - imports: [BrowserModule, imports], + imports: [BrowserModule], entryComponents: entryComponents, bootstrap: [appComponentType], - schemas: schemas + schemas: [CUSTOM_ELEMENTS_SCHEMA] }) class DynamicModule { } diff --git a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts index 293f25d946..4eba90a646 100644 --- a/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts +++ b/modules/@angular/platform-browser/test/browser/bootstrap_spec.ts @@ -333,10 +333,7 @@ export function main() { })); it('should allow to pass schemas', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - bootstrap(HelloCmpUsingCustomElement, { - providers: testProviders, - schemas: [CUSTOM_ELEMENTS_SCHEMA] - }).then((compRef) => { + bootstrap(HelloCmpUsingCustomElement, testProviders).then((compRef) => { expect(el).toHaveText('hello world!'); async.done(); }); diff --git a/modules/playground/src/routing/index.ts b/modules/playground/src/routing/index.ts index bce844afbc..df1c7280a6 100644 --- a/modules/playground/src/routing/index.ts +++ b/modules/playground/src/routing/index.ts @@ -6,16 +6,21 @@ * found in the LICENSE file at https://angular.io/license */ -import {HashLocationStrategy, LocationStrategy} from '@angular/common'; -import {bootstrap} from '@angular/platform-browser-dynamic'; +import {NgModule} from '@angular/core'; +import {BrowserModule} from '@angular/platform-browser'; +import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {RouterModule} from '@angular/router'; import {DbService, DraftsCmp, InboxApp, InboxCmp, ROUTER_CONFIG} from './app/inbox-app'; export function main() { - bootstrap(InboxApp, { + @NgModule({ providers: [DbService], - declarations: [InboxCmp, DraftsCmp], - imports: [RouterModule.forRoot(ROUTER_CONFIG, {useHash: true})] - }); + declarations: [InboxCmp, DraftsCmp, InboxApp], + imports: [RouterModule.forRoot(ROUTER_CONFIG, {useHash: true}), BrowserModule], + bootstrap: [InboxApp] + }) + class RoutingExampleModule { + } + platformBrowserDynamic().bootstrapModule(RoutingExampleModule); } diff --git a/tools/public_api_guard/platform-browser-dynamic/index.d.ts b/tools/public_api_guard/platform-browser-dynamic/index.d.ts index ea303c131c..f3cf49a1e9 100644 --- a/tools/public_api_guard/platform-browser-dynamic/index.d.ts +++ b/tools/public_api_guard/platform-browser-dynamic/index.d.ts @@ -1,4 +1,4 @@ -/** @experimental */ +/** @deprecated */ export declare function bootstrap(appComponentType: ConcreteType, customProviders?: Array): Promise>; /** @deprecated */