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:
parent
245b0910ed
commit
daa9da4047
|
@ -132,9 +132,7 @@ export class CodeGenerator {
|
|||
genDebugInfo: options.debug === true,
|
||||
defaultEncapsulation: ViewEncapsulation.Emulated,
|
||||
logBindingUpdate: false,
|
||||
useJit: false,
|
||||
platformDirectives: [],
|
||||
platformPipes: []
|
||||
useJit: false
|
||||
});
|
||||
const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config);
|
||||
const parser = new Parser(new Lexer());
|
||||
|
|
|
@ -142,9 +142,7 @@ class Extractor {
|
|||
genDebugInfo: true,
|
||||
defaultEncapsulation: ViewEncapsulation.Emulated,
|
||||
logBindingUpdate: false,
|
||||
useJit: false,
|
||||
platformDirectives: [],
|
||||
platformPipes: []
|
||||
useJit: false
|
||||
});
|
||||
const normalizer = new DirectiveNormalizer(xhr, urlResolver, htmlParser, config);
|
||||
const parser = new Parser(new Lexer());
|
||||
|
|
|
@ -92,8 +92,8 @@ export class _RuntimeCompilerFactory extends CompilerFactory {
|
|||
const inj = ReflectiveInjector.resolveAndCreate(options.deprecatedAppProviders);
|
||||
const compilerConfig: CompilerConfig = inj.get(CompilerConfig, null);
|
||||
if (compilerConfig) {
|
||||
platformDirectivesFromAppProviders = compilerConfig.platformDirectives;
|
||||
platformPipesFromAppProviders = compilerConfig.platformPipes;
|
||||
platformDirectivesFromAppProviders = compilerConfig.deprecatedPlatformDirectives;
|
||||
platformPipesFromAppProviders = compilerConfig.deprecatedPlatformPipes;
|
||||
useJitFromAppProviders = compilerConfig.useJit;
|
||||
useDebugFromAppProviders = compilerConfig.genDebugInfo;
|
||||
defaultEncapsulationFromAppProviders = compilerConfig.defaultEncapsulation;
|
||||
|
@ -133,9 +133,9 @@ export class _RuntimeCompilerFactory extends CompilerFactory {
|
|||
provide: CompilerConfig,
|
||||
useFactory: (platformDirectives: any[], platformPipes: any[]) => {
|
||||
return new CompilerConfig({
|
||||
platformDirectives:
|
||||
deprecatedPlatformDirectives:
|
||||
_mergeArrays(platformDirectivesFromAppProviders, platformDirectives),
|
||||
platformPipes: _mergeArrays(platformPipesFromAppProviders, platformPipes),
|
||||
deprecatedPlatformPipes: _mergeArrays(platformPipesFromAppProviders, platformPipes),
|
||||
// let explicit values from the compiler options overwrite options
|
||||
// from the app providers. E.g. important for the testing platform.
|
||||
genDebugInfo: _firstDefined(options.useDebug, useDebugFromAppProviders, isDevMode()),
|
||||
|
|
|
@ -19,28 +19,38 @@ export class CompilerConfig {
|
|||
private _genDebugInfo: boolean;
|
||||
private _logBindingUpdate: boolean;
|
||||
public useJit: boolean;
|
||||
public platformDirectives: any[];
|
||||
public platformPipes: any[];
|
||||
/**
|
||||
* @deprecated Providing platform directives via the {@link CompilerConfig} deprecated. Provide
|
||||
* platform
|
||||
* directives via an {@link AppModule} instead.
|
||||
*/
|
||||
public deprecatedPlatformDirectives: any[];
|
||||
/**
|
||||
* @deprecated Providing platform pipes via the {@link CompilerConfig} deprecated. Provide
|
||||
* platform pipes
|
||||
* via an {@link AppModule} instead.
|
||||
*/
|
||||
public deprecatedPlatformPipes: any[];
|
||||
|
||||
constructor(
|
||||
{renderTypes = new DefaultRenderTypes(), defaultEncapsulation = ViewEncapsulation.Emulated,
|
||||
genDebugInfo, logBindingUpdate, useJit = true, platformDirectives = [],
|
||||
platformPipes = []}: {
|
||||
genDebugInfo, logBindingUpdate, useJit = true, deprecatedPlatformDirectives = [],
|
||||
deprecatedPlatformPipes = []}: {
|
||||
renderTypes?: RenderTypes,
|
||||
defaultEncapsulation?: ViewEncapsulation,
|
||||
genDebugInfo?: boolean,
|
||||
logBindingUpdate?: boolean,
|
||||
useJit?: boolean,
|
||||
platformDirectives?: any[],
|
||||
platformPipes?: any[]
|
||||
deprecatedPlatformDirectives?: any[],
|
||||
deprecatedPlatformPipes?: any[]
|
||||
} = {}) {
|
||||
this.renderTypes = renderTypes;
|
||||
this.defaultEncapsulation = defaultEncapsulation;
|
||||
this._genDebugInfo = genDebugInfo;
|
||||
this._logBindingUpdate = logBindingUpdate;
|
||||
this.useJit = useJit;
|
||||
this.platformDirectives = platformDirectives;
|
||||
this.platformPipes = platformPipes;
|
||||
this.deprecatedPlatformDirectives = deprecatedPlatformDirectives;
|
||||
this.deprecatedPlatformPipes = deprecatedPlatformPipes;
|
||||
}
|
||||
|
||||
get genDebugInfo(): boolean {
|
||||
|
|
|
@ -301,7 +301,7 @@ export class CompileMetadataResolver {
|
|||
|
||||
getViewDirectivesMetadata(component: Type): cpl.CompileDirectiveMetadata[] {
|
||||
var view = this._viewResolver.resolve(component);
|
||||
var directives = flattenDirectives(view, this._config.platformDirectives);
|
||||
var directives = flattenDirectives(view, this._config.deprecatedPlatformDirectives);
|
||||
for (var i = 0; i < directives.length; i++) {
|
||||
if (!isValidType(directives[i])) {
|
||||
throw new BaseException(
|
||||
|
@ -313,7 +313,7 @@ export class CompileMetadataResolver {
|
|||
|
||||
getViewPipesMetadata(component: Type): cpl.CompilePipeMetadata[] {
|
||||
var view = this._viewResolver.resolve(component);
|
||||
var pipes = flattenPipes(view, this._config.platformPipes);
|
||||
var pipes = flattenPipes(view, this._config.deprecatedPlatformPipes);
|
||||
for (var i = 0; i < pipes.length; i++) {
|
||||
if (!isValidType(pipes[i])) {
|
||||
throw new BaseException(
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import {AppModuleFactory, AppModuleMetadata, Compiler, ComponentFactory, ComponentResolver, ComponentStillLoadingError, Injectable, Injector, OptionalMetadata, Provider, SkipSelfMetadata} from '@angular/core';
|
||||
import {Console} from '../core_private';
|
||||
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
import {ConcreteType, IS_DART, Type, isBlank, isString, stringify} from '../src/facade/lang';
|
||||
|
@ -42,11 +43,28 @@ export class RuntimeCompiler implements ComponentResolver, Compiler {
|
|||
private _compiledHostTemplateCache = new Map<Type, CompiledTemplate>();
|
||||
private _compiledAppModuleCache = new Map<Type, AppModuleFactory<any>>();
|
||||
|
||||
private _warnOnComponentResolver = true;
|
||||
|
||||
constructor(
|
||||
private _injector: Injector, private _metadataResolver: CompileMetadataResolver,
|
||||
private _templateNormalizer: DirectiveNormalizer, private _templateParser: TemplateParser,
|
||||
private _styleCompiler: StyleCompiler, private _viewCompiler: ViewCompiler,
|
||||
private _appModuleCompiler: AppModuleCompiler, private _genConfig: CompilerConfig) {}
|
||||
private _appModuleCompiler: AppModuleCompiler, private _genConfig: CompilerConfig,
|
||||
private _console: Console) {
|
||||
const flatDeprecatedPlatformDirectives =
|
||||
ListWrapper.flatten(_genConfig.deprecatedPlatformDirectives);
|
||||
if (flatDeprecatedPlatformDirectives.length > 0) {
|
||||
this._console.warn(
|
||||
`Providing platform directives via the PLATFORM_DIRECTIVES provider or the "CompilerConfig" is deprecated. Provide platform directives via an @AppModule instead. Directives: ` +
|
||||
flatDeprecatedPlatformDirectives.map(stringify));
|
||||
}
|
||||
const flatDeprecatedPlatformPipes = ListWrapper.flatten(_genConfig.deprecatedPlatformPipes);
|
||||
if (flatDeprecatedPlatformPipes.length > 0) {
|
||||
this._console.warn(
|
||||
`Providing platform pipes via the PLATFORM_PIPES provider or the "CompilerConfig" is deprecated. Provide platform pipes via an @AppModule instead. Pipes: ` +
|
||||
flatDeprecatedPlatformPipes.map(stringify));
|
||||
}
|
||||
}
|
||||
|
||||
get injector(): Injector { return this._injector; }
|
||||
|
||||
|
@ -55,6 +73,10 @@ export class RuntimeCompiler implements ComponentResolver, Compiler {
|
|||
return PromiseWrapper.reject(
|
||||
new BaseException(`Cannot resolve component using '${component}'.`), null);
|
||||
}
|
||||
if (this._warnOnComponentResolver) {
|
||||
this._console.warn(ComponentResolver.DynamicCompilationDeprecationMsg);
|
||||
this._warnOnComponentResolver = false;
|
||||
}
|
||||
return this.compileComponentAsync(<ConcreteType<any>>component);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,8 +115,8 @@ export function main() {
|
|||
configureCompiler({
|
||||
providers: [{
|
||||
provide: CompilerConfig,
|
||||
useValue:
|
||||
new CompilerConfig({genDebugInfo: true, platformDirectives: [ADirective]})
|
||||
useValue: new CompilerConfig(
|
||||
{genDebugInfo: true, deprecatedPlatformDirectives: [ADirective]})
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
|
|
@ -235,10 +235,12 @@ export function bootstrapModule<M>(
|
|||
* Shortcut for ApplicationRef.bootstrap.
|
||||
* Requires a platform to be created first.
|
||||
*
|
||||
* @experimental APIs related to application bootstrap are currently under review.
|
||||
* @deprecated Use {@link bootstrapModuleFactory} instead.
|
||||
*/
|
||||
export function coreBootstrap<C>(
|
||||
componentFactory: ComponentFactory<C>, injector: Injector): ComponentRef<C> {
|
||||
let console = injector.get(Console);
|
||||
console.warn('coreBootstrap is deprecated. Use bootstrapModuleFactory instead.');
|
||||
var appRef: ApplicationRef = injector.get(ApplicationRef);
|
||||
return appRef.bootstrap(componentFactory);
|
||||
}
|
||||
|
@ -248,10 +250,12 @@ export function coreBootstrap<C>(
|
|||
* waits for asynchronous initializers and bootstraps the component.
|
||||
* Requires a platform to be created first.
|
||||
*
|
||||
* @experimental APIs related to application bootstrap are currently under review.
|
||||
* @deprecated Use {@link bootstrapModule} instead.
|
||||
*/
|
||||
export function coreLoadAndBootstrap(
|
||||
componentType: Type, injector: Injector): Promise<ComponentRef<any>> {
|
||||
let console = injector.get(Console);
|
||||
console.warn('coreLoadAndBootstrap is deprecated. Use bootstrapModule instead.');
|
||||
var appRef: ApplicationRef = injector.get(ApplicationRef);
|
||||
return appRef.run(() => {
|
||||
var componentResolver: ComponentResolver = injector.get(ComponentResolver);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Console} from '../console';
|
||||
import {Injectable} from '../di/decorators';
|
||||
import {PromiseWrapper} from '../facade/async';
|
||||
import {BaseException} from '../facade/exceptions';
|
||||
|
@ -18,9 +19,19 @@ import {ComponentFactory} from './component_factory';
|
|||
/**
|
||||
* Low-level service for loading {@link ComponentFactory}s, which
|
||||
* can later be used to create and render a Component instance.
|
||||
* @experimental
|
||||
*
|
||||
* @deprecated Use {@link ComponentFactoryResolver} together with {@link
|
||||
* AppModule}.precompile}/{@link Component}.precompile or
|
||||
* {@link ANALYZE_FOR_PRECOMPILE} provider for dynamic component creation.
|
||||
* Use {@link AppModuleFactoryLoader} for lazy loading.
|
||||
*/
|
||||
export abstract class ComponentResolver {
|
||||
static DynamicCompilationDeprecationMsg =
|
||||
'ComponentResolver is deprecated for dynamic compilation. Use ComponentFactoryResolver together with @AppModule/@Component.precompile or ANALYZE_FOR_PRECOMPILE provider instead.';
|
||||
static LazyLoadingDeprecationMsg =
|
||||
'ComponentResolver is deprecated for lazy loading. Use AppModuleFactoryLoader instead.';
|
||||
|
||||
|
||||
abstract resolveComponent(component: Type|string): Promise<ComponentFactory<any>>;
|
||||
abstract clearCache(): void;
|
||||
}
|
||||
|
@ -31,11 +42,13 @@ function _isComponentFactory(type: any): boolean {
|
|||
|
||||
@Injectable()
|
||||
export class ReflectorComponentResolver extends ComponentResolver {
|
||||
constructor(private _console: Console) { super(); }
|
||||
resolveComponent(component: Type|string): Promise<ComponentFactory<any>> {
|
||||
if (isString(component)) {
|
||||
return PromiseWrapper.reject(
|
||||
new BaseException(`Cannot resolve component using '${component}'.`), null);
|
||||
}
|
||||
this._console.warn(ComponentResolver.DynamicCompilationDeprecationMsg);
|
||||
|
||||
var metadatas = reflector.annotations(<Type>component);
|
||||
var componentFactory = metadatas.find(_isComponentFactory);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Console} from '../console';
|
||||
import {Injectable} from '../di';
|
||||
import {Type, global, isString} from '../facade/lang';
|
||||
|
||||
import {ComponentFactory} from './component_factory';
|
||||
|
@ -15,13 +17,18 @@ const _SEPARATOR = '#';
|
|||
|
||||
/**
|
||||
* Component resolver that can load components lazily
|
||||
* @experimental
|
||||
*
|
||||
* @deprecated Lazy loading of components is deprecated. Use {@link SystemJsAppModuleLoader} to lazy
|
||||
* load
|
||||
* {@link AppModuleFactory}s instead.
|
||||
*/
|
||||
@Injectable()
|
||||
export class SystemJsComponentResolver implements ComponentResolver {
|
||||
constructor(private _resolver: ComponentResolver) {}
|
||||
constructor(private _resolver: ComponentResolver, private _console: Console) {}
|
||||
|
||||
resolveComponent(componentType: string|Type): Promise<ComponentFactory<any>> {
|
||||
if (isString(componentType)) {
|
||||
this._console.warn(ComponentResolver.LazyLoadingDeprecationMsg);
|
||||
let [module, component] = componentType.split(_SEPARATOR);
|
||||
|
||||
if (component === void(0)) {
|
||||
|
@ -45,11 +52,17 @@ const FACTORY_CLASS_SUFFIX = 'NgFactory';
|
|||
|
||||
/**
|
||||
* Component resolver that can load component factories lazily
|
||||
* @experimental
|
||||
*
|
||||
* @deprecated Lazy loading of components is deprecated. Use {@link SystemJsAppModuleFactoryLoader}
|
||||
* to lazy
|
||||
* load {@link AppModuleFactory}s instead.
|
||||
*/
|
||||
@Injectable()
|
||||
export class SystemJsCmpFactoryResolver implements ComponentResolver {
|
||||
constructor(private _console: Console) {}
|
||||
resolveComponent(componentType: string|Type): Promise<ComponentFactory<any>> {
|
||||
if (isString(componentType)) {
|
||||
this._console.warn(ComponentResolver.LazyLoadingDeprecationMsg);
|
||||
let [module, factory] = componentType.split(_SEPARATOR);
|
||||
return (<any>global)
|
||||
.System.import(module + FACTORY_MODULE_SUFFIX)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {OpaqueToken} from './di';
|
||||
|
||||
/**
|
||||
A token that can be provided when bootstrapping an application to make an array of directives
|
||||
* A token that can be provided when bootstrapping an application to make an array of directives
|
||||
* available in every component of the application.
|
||||
*
|
||||
* ### Example
|
||||
|
@ -32,9 +32,10 @@ import {OpaqueToken} from './di';
|
|||
* bootstrap(MyComponent, [{provide: PLATFORM_DIRECTIVES, useValue: [OtherDirective],
|
||||
multi:true}]);
|
||||
* ```
|
||||
* @stable
|
||||
*
|
||||
* @deprecated Providing platform directives via a provider is deprecated. Provide platform
|
||||
* directives via an {@link AppModule} instead.
|
||||
*/
|
||||
|
||||
export const PLATFORM_DIRECTIVES: OpaqueToken =
|
||||
/*@ts2dart_const*/ new OpaqueToken('Platform Directives');
|
||||
|
||||
|
@ -60,7 +61,8 @@ export const PLATFORM_DIRECTIVES: OpaqueToken =
|
|||
*
|
||||
* bootstrap(MyComponent, [{provide: PLATFORM_PIPES, useValue: [OtherPipe], multi:true}]);
|
||||
* ```
|
||||
* @stable
|
||||
*
|
||||
* @deprecated Providing platform pipes via a provider is deprecated. Provide platform pipes via an
|
||||
* {@link AppModule} instead.
|
||||
*/
|
||||
|
||||
export const PLATFORM_PIPES: OpaqueToken = /*@ts2dart_const*/ new OpaqueToken('Platform Pipes');
|
|
@ -12,6 +12,12 @@ import {ComponentResolver, ReflectorComponentResolver} from '@angular/core/src/l
|
|||
import {ReflectionInfo, reflector} from '@angular/core/src/reflection/reflection';
|
||||
import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Console} from '../../src/console';
|
||||
|
||||
class DummyConsole implements Console {
|
||||
log(message: string) {}
|
||||
warn(message: string) {}
|
||||
}
|
||||
|
||||
export function main() {
|
||||
describe('Compiler', () => {
|
||||
|
@ -21,7 +27,7 @@ export function main() {
|
|||
beforeEach(() => {
|
||||
someCompFactory = new ComponentFactory(null, null, null);
|
||||
reflector.registerType(SomeComponent, new ReflectionInfo([someCompFactory]));
|
||||
compiler = new ReflectorComponentResolver();
|
||||
compiler = new ReflectorComponentResolver(new DummyConsole());
|
||||
});
|
||||
|
||||
it('should read the template from an annotation',
|
||||
|
|
|
@ -19,13 +19,17 @@ import {CachedXHR} from './src/xhr/xhr_cache';
|
|||
import {XHRImpl} from './src/xhr/xhr_impl';
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @deprecated The compiler providers are already included in the {@link CompilerFactory} that is
|
||||
* contained the {@link browserDynamicPlatform}()`.
|
||||
*/
|
||||
export const BROWSER_APP_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
COMPILER_PROVIDERS, {
|
||||
provide: CompilerConfig,
|
||||
useFactory: (platformDirectives: any[], platformPipes: any[]) => {
|
||||
return new CompilerConfig({platformDirectives, platformPipes});
|
||||
return new CompilerConfig({
|
||||
deprecatedPlatformDirectives: platformDirectives,
|
||||
deprecatedPlatformPipes: platformPipes
|
||||
});
|
||||
},
|
||||
deps: [PLATFORM_DIRECTIVES, PLATFORM_PIPES]
|
||||
},
|
||||
|
@ -208,11 +212,15 @@ export function bootstrap<C>(
|
|||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @deprecated Create an {@link AppModule} that includes the {@link WorkerUiModule} and use {@link
|
||||
* bootstrapModule}
|
||||
* with the {@link workerUiPlatform}() instead.
|
||||
*/
|
||||
export function bootstrapWorkerUi(
|
||||
workerScriptUri: string,
|
||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ApplicationRef> {
|
||||
console.warn(
|
||||
'bootstrapWorkerUi is deprecated. Create an @AppModule that includes the `WorkerUiModule` and use `bootstrapModule` with the `workerUiPlatform()` instead.');
|
||||
var app = ReflectiveInjector.resolveAndCreate(
|
||||
[
|
||||
WORKER_UI_APPLICATION_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS,
|
||||
|
@ -227,13 +235,17 @@ export function bootstrapWorkerUi(
|
|||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @deprecated The compiler providers are already included in the {@link CompilerFactory} that is
|
||||
* contained the {@link workerAppPlatform}().
|
||||
*/
|
||||
const WORKER_APP_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
||||
COMPILER_PROVIDERS, {
|
||||
provide: CompilerConfig,
|
||||
useFactory: (platformDirectives: any[], platformPipes: any[]) => {
|
||||
return new CompilerConfig({platformDirectives, platformPipes});
|
||||
return new CompilerConfig({
|
||||
deprecatedPlatformDirectives: platformDirectives,
|
||||
deprecatedPlatformPipes: platformPipes
|
||||
});
|
||||
},
|
||||
deps: [PLATFORM_DIRECTIVES, PLATFORM_PIPES]
|
||||
},
|
||||
|
@ -244,11 +256,15 @@ const WORKER_APP_COMPILER_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
|||
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @deprecated Create an {@link AppModule} that includes the {@link WorkerAppModule} and use {@link
|
||||
* bootstrapModule}
|
||||
* with the {@link workerAppPlatform}() instead.
|
||||
*/
|
||||
export function bootstrapWorkerApp(
|
||||
appComponentType: Type,
|
||||
customProviders?: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
|
||||
console.warn(
|
||||
'bootstrapWorkerApp is deprecated. Create an @AppModule that includes the `WorkerAppModule` and use `bootstrapModule` with the `workerAppPlatform()` instead.');
|
||||
var appInjector = ReflectiveInjector.resolveAndCreate(
|
||||
[
|
||||
WORKER_APP_APPLICATION_PROVIDERS, WORKER_APP_COMPILER_PROVIDERS,
|
||||
|
|
|
@ -325,7 +325,9 @@ export function main() {
|
|||
|
||||
expect(compilerConsole.warnings).toEqual([
|
||||
'Passing PLATFORM_DIRECTIVES to "bootstrap()" as provider is deprecated. Use the new parameter "directives" of "bootstrap()" instead.',
|
||||
'Passing PLATFORM_PIPES to "bootstrap()" as provider is deprecated. Use the new parameter "pipes" of "bootstrap()" instead.'
|
||||
'Passing PLATFORM_PIPES to "bootstrap()" as provider is deprecated. Use the new parameter "pipes" of "bootstrap()" instead.',
|
||||
`Providing platform directives via the PLATFORM_DIRECTIVES provider or the "CompilerConfig" is deprecated. Provide platform directives via an @AppModule instead. Directives: ${stringify(SomeDirective)}`,
|
||||
`Providing platform pipes via the PLATFORM_PIPES provider or the "CompilerConfig" is deprecated. Provide platform pipes via an @AppModule instead. Pipes: ${stringify(SomePipe)}`
|
||||
]);
|
||||
async.done();
|
||||
});
|
||||
|
|
|
@ -81,11 +81,15 @@ export const serverDynamicPlatform =
|
|||
* serverBootstrap(..., [BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS])
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
* @deprecated create an {@link AppModule} and use {@link bootstrapModule} with the {@link
|
||||
* serverDynamicPlatform}()
|
||||
* instead.
|
||||
*/
|
||||
export function serverBootstrap(
|
||||
appComponentType: Type,
|
||||
providers: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<any>> {
|
||||
console.warn(
|
||||
'serverBootstrap is deprecated. Create an @AppModule and use `bootstrapModule` with the `serverDynamicPlatform()` instead.');
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
var appInjector = ReflectiveInjector.resolveAndCreate(providers, serverPlatform().injector);
|
||||
return coreLoadAndBootstrap(appComponentType, appInjector);
|
||||
|
|
|
@ -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,
|
||||
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
|
||||
],
|
||||
platformRef.injector)
|
||||
.get(ApplicationRef);
|
||||
{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;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {Class, Component, EventEmitter, Testability, disposePlatform, provide} from '@angular/core';
|
||||
import {AsyncTestCompleter, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {AsyncTestCompleter, ddescribe, describe, expect, iit, inject, it} from '@angular/core/testing/testing_internal';
|
||||
import {UpgradeAdapter} from '@angular/upgrade';
|
||||
import * as angular from '@angular/upgrade/src/angular_js';
|
||||
|
||||
|
|
|
@ -471,10 +471,12 @@ export declare abstract class ComponentRef<C> {
|
|||
abstract onDestroy(callback: Function): void;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare abstract class ComponentResolver {
|
||||
abstract clearCache(): void;
|
||||
abstract resolveComponent(component: Type | string): Promise<ComponentFactory<any>>;
|
||||
static DynamicCompilationDeprecationMsg: string;
|
||||
static LazyLoadingDeprecationMsg: string;
|
||||
}
|
||||
|
||||
/** @stable */
|
||||
|
@ -526,10 +528,10 @@ export interface ContentChildrenMetadataFactory {
|
|||
}): ContentChildrenMetadata;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare function coreBootstrap<C>(componentFactory: ComponentFactory<C>, injector: Injector): ComponentRef<C>;
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare function coreLoadAndBootstrap(componentType: Type, injector: Injector): Promise<ComponentRef<any>>;
|
||||
|
||||
/** @experimental */
|
||||
|
@ -1057,13 +1059,13 @@ export interface PipeTransform {
|
|||
/** @experimental */
|
||||
export declare const PLATFORM_COMMON_PROVIDERS: Array<any | Type | Provider | any[]>;
|
||||
|
||||
/** @stable */
|
||||
/** @deprecated */
|
||||
export declare const PLATFORM_DIRECTIVES: OpaqueToken;
|
||||
|
||||
/** @experimental */
|
||||
export declare const PLATFORM_INITIALIZER: any;
|
||||
|
||||
/** @stable */
|
||||
/** @deprecated */
|
||||
export declare const PLATFORM_PIPES: OpaqueToken;
|
||||
|
||||
/** @experimental */
|
||||
|
@ -1338,15 +1340,16 @@ export declare class SystemJsAppModuleLoader implements AppModuleFactoryLoader {
|
|||
load(path: string): Promise<AppModuleFactory<any>>;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare class SystemJsCmpFactoryResolver implements ComponentResolver {
|
||||
constructor(_console: Console);
|
||||
clearCache(): void;
|
||||
resolveComponent(componentType: string | Type): Promise<ComponentFactory<any>>;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare class SystemJsComponentResolver implements ComponentResolver {
|
||||
constructor(_resolver: ComponentResolver);
|
||||
constructor(_resolver: ComponentResolver, _console: Console);
|
||||
clearCache(): void;
|
||||
resolveComponent(componentType: string | Type): Promise<ComponentFactory<any>>;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/** @experimental */
|
||||
export declare function bootstrap<C>(appComponentType: ConcreteType<C>, customProviders?: Array<any>): Promise<ComponentRef<C>>;
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare function bootstrapWorkerApp(appComponentType: Type, customProviders?: Array<any>): Promise<ComponentRef<any>>;
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: Array<any>): Promise<ApplicationRef>;
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare const BROWSER_APP_COMPILER_PROVIDERS: Array<any>;
|
||||
|
||||
/** @experimental */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @experimental */
|
||||
export declare const SERVER_PLATFORM_PROVIDERS: Array<any>;
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare function serverBootstrap(appComponentType: Type, providers: Array<any>): Promise<ComponentRef<any>>;
|
||||
|
||||
/** @experimental */
|
||||
|
|
Loading…
Reference in New Issue