refactor(core): deprecate coreBootstrap
, PLATFORM_PIPES/DIRECTIVES
providers and ComponentResolver
BREAKING CHANGE (deprecations) - Instead of `coreBootstrap`, create an `@AppModule` and use `bootstrapModule`. - Instead of `coreLoadAndBootstarp`, create an `@AppModule` and use `bootstrapModuleFactory`. - Instead of `bootstrapWorkerApp`, create an `@AppModule` that includes the `WorkerAppModule` and use `bootstrapModule` with the `workerAppPlatform()`. - Instead of `bootstrapWorkerUi`, create an @AppModule that includes the `WorkerUiModule` and use `bootstrapModule` with the `workerUiPlatform()` instead. - Instead of `serverBootstrap`, create an @AppModule and use `bootstrapModule` with the `serverDynamicPlatform()` instead. - Instead of `PLATFORM_PIPES` and `PLATFORM_DIRECTIVES`, provide platform directives/pipes via an `@AppModule`. - Instead of `ComponentResolver`: - use `ComponentFactoryResolver` together with `@AppModule.precompile`/`@Component.precompile` or `ANALYZE_FOR_PRECOMPILE` provider for dynamic component creation. - use `AppModuleFactoryLoader` for lazy loading. - Instead of `SystemJsComponentResolver`, create an `@AppModule` and use `SystemJsAppModuleLoader`. - Instead of `SystemJsCmpFactoryResolver`, create an `@AppModule` and use `SystemJsAppModuleFactoryLoader` Closes #9726
This commit is contained in:
@ -6,9 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ApplicationRef, ComponentFactory, ComponentResolver, Injector, NgZone, PlatformRef, Provider, ReflectiveInjector, Testability, Type, provide} from '@angular/core';
|
||||
import {BROWSER_APP_PROVIDERS, browserPlatform} from '@angular/platform-browser';
|
||||
import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';
|
||||
import {AppModule, ApplicationRef, Compiler, CompilerFactory, ComponentFactory, ComponentResolver, Injector, NgZone, PlatformRef, Provider, ReflectiveInjector, Testability, Type, bootstrapModuleFactory, provide} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {browserDynamicPlatform} 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,21 +278,22 @@ export class UpgradeAdapter {
|
||||
UpgradeAdapterRef {
|
||||
var upgrade = new UpgradeAdapterRef();
|
||||
var ng1Injector: angular.IInjectorService = null;
|
||||
var platformRef: PlatformRef = browserPlatform();
|
||||
var applicationRef: ApplicationRef =
|
||||
ReflectiveInjector
|
||||
.resolveAndCreate(
|
||||
[
|
||||
BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS,
|
||||
{provide: NG1_INJECTOR, useFactory: () => ng1Injector},
|
||||
{provide: NG1_COMPILE, useFactory: () => ng1Injector.get(NG1_COMPILE)},
|
||||
this.providers
|
||||
],
|
||||
platformRef.injector)
|
||||
.get(ApplicationRef);
|
||||
var platformRef: PlatformRef = browserDynamicPlatform();
|
||||
var compiler: Compiler = platformRef.injector.get(CompilerFactory).createCompiler();
|
||||
var providers = [
|
||||
{provide: NG1_INJECTOR, useFactory: () => ng1Injector},
|
||||
{provide: NG1_COMPILE, useFactory: () => ng1Injector.get(NG1_COMPILE)}, this.providers
|
||||
];
|
||||
|
||||
@AppModule({providers: providers, modules: [BrowserModule]})
|
||||
class DynamicModule {
|
||||
}
|
||||
|
||||
var moduleRef =
|
||||
bootstrapModuleFactory(compiler.compileAppModuleSync(DynamicModule), platformRef);
|
||||
var applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
|
||||
var injector: Injector = applicationRef.injector;
|
||||
var ngZone: NgZone = injector.get(NgZone);
|
||||
var compiler: ComponentResolver = injector.get(ComponentResolver);
|
||||
var delayApplyExps: Function[] = [];
|
||||
var original$applyFn: Function;
|
||||
var rootScopePrototype: any;
|
||||
@ -510,13 +511,12 @@ export class UpgradeAdapter {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
private compileNg2Components(
|
||||
compiler: ComponentResolver,
|
||||
componentFactoryRefMap: ComponentFactoryRefMap): Promise<ComponentFactoryRefMap> {
|
||||
private compileNg2Components(compiler: Compiler, componentFactoryRefMap: ComponentFactoryRefMap):
|
||||
Promise<ComponentFactoryRefMap> {
|
||||
var promises: Array<Promise<ComponentFactory<any>>> = [];
|
||||
var types = this.upgradedComponents;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
promises.push(compiler.resolveComponent(types[i]));
|
||||
promises.push(compiler.compileComponentAsync(<any>types[i]));
|
||||
}
|
||||
return Promise.all(promises).then((componentFactories: Array<ComponentFactory<any>>) => {
|
||||
var types = this.upgradedComponents;
|
||||
|
Reference in New Issue
Block a user