cleanup(platform): removed webworker and server deprecated apis (#10745)
This commit is contained in:
@ -6,4 +6,4 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
export {SERVER_PLATFORM_PROVIDERS, platformDynamicServer, platformServer, serverBootstrap, serverDynamicPlatform, serverPlatform} from './src/server';
|
||||
export {ServerModule, platformDynamicServer, platformServer} from './src/server';
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {PlatformLocation} from '@angular/common';
|
||||
import {analyzeAppProvidersForDeprecatedConfiguration, platformCoreDynamic} from '@angular/compiler';
|
||||
import {ApplicationRef, ComponentRef, NgModule, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, PlatformRef, Type, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {ApplicationRef, ComponentRef, NgModule, PLATFORM_INITIALIZER, PlatformRef, Type, createPlatformFactory, platformCore} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
|
||||
import {Console, ReflectionCapabilities, reflector, wtfInit} from '../core_private';
|
||||
@ -37,89 +37,30 @@ export const INTERNAL_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | a
|
||||
{provide: PlatformLocation, useClass: ServerPlatformLocation},
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* A set of providers to initialize the Angular platform in a server.
|
||||
*
|
||||
* Used automatically by `serverBootstrap`, or can be passed to `platform`.
|
||||
* @deprecated Use `platformServer()` or create a custom platform factory via
|
||||
* `createPlatformFactory(platformServer, ...)`
|
||||
*/
|
||||
export const SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[PLATFORM_COMMON_PROVIDERS, INTERNAL_SERVER_PLATFORM_PROVIDERS];
|
||||
|
||||
function initParse5Adapter() {
|
||||
Parse5DomAdapter.makeCurrent();
|
||||
wtfInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* The ng module for the server.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
@NgModule({imports: [BrowserModule]})
|
||||
export class ServerModule {
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
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 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).
|
||||
*
|
||||
* This version of bootstrap only creates platform injector and does not define anything for
|
||||
* application injector. It is expected that application providers are imported from other
|
||||
* packages such as `@angular/platform-browser` or `@angular/platform-browser-dynamic`.
|
||||
*
|
||||
* ```
|
||||
* import {BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
|
||||
* import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';
|
||||
*
|
||||
* serverBootstrap(..., [BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS])
|
||||
* ```
|
||||
*
|
||||
* @deprecated create an {@link NgModule} and use {@link bootstrapModule} with the {@link
|
||||
* serverDynamicPlatform}()
|
||||
* instead.
|
||||
*/
|
||||
export function serverBootstrap<T>(
|
||||
appComponentType: Type<T>,
|
||||
customProviders: Array<any /*Type | Provider | any[]*/>): Promise<ComponentRef<T>> {
|
||||
console.warn(
|
||||
'serverBootstrap is deprecated. Create an @NgModule and use `bootstrapModule` with the `serverDynamicPlatform()` instead.');
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
|
||||
const deprecatedConfiguration = analyzeAppProvidersForDeprecatedConfiguration(customProviders);
|
||||
const declarations = [deprecatedConfiguration.moduleDeclarations.concat([appComponentType])];
|
||||
|
||||
@NgModule({
|
||||
providers: customProviders,
|
||||
declarations: declarations,
|
||||
imports: [BrowserModule],
|
||||
bootstrap: [appComponentType]
|
||||
})
|
||||
class DynamicModule {
|
||||
}
|
||||
|
||||
return platformDynamicServer()
|
||||
.bootstrapModule(DynamicModule, deprecatedConfiguration.compilerOptions)
|
||||
.then((moduleRef) => {
|
||||
const console = moduleRef.injector.get(Console);
|
||||
deprecatedConfiguration.deprecationMessages.forEach((msg) => console.warn(msg));
|
||||
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
|
||||
return appRef.components[0];
|
||||
});
|
||||
}
|
||||
createPlatformFactory(platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS);
|
@ -6,12 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, destroyPlatform} from '@angular/core';
|
||||
import {Component, NgModule, destroyPlatform} from '@angular/core';
|
||||
import {async} from '@angular/core/testing';
|
||||
import {BROWSER_APP_PROVIDERS} from '@angular/platform-browser';
|
||||
import {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {serverBootstrap} from '@angular/platform-server';
|
||||
import {ServerModule, platformDynamicServer} from '@angular/platform-server';
|
||||
|
||||
function writeBody(html: string): any {
|
||||
var dom = getDOM();
|
||||
@ -21,6 +19,15 @@ function writeBody(html: string): any {
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
@Component({selector: 'app', template: `Works!`})
|
||||
class MyServerApp {
|
||||
}
|
||||
|
||||
@NgModule({imports: [ServerModule], bootstrap: [MyServerApp]})
|
||||
class ExampleModule {
|
||||
}
|
||||
|
||||
export function main() {
|
||||
if (getDOM().supportsDOMEvents()) return; // NODE only
|
||||
|
||||
@ -31,13 +38,9 @@ export function main() {
|
||||
|
||||
it('should bootstrap', async(() => {
|
||||
var body = writeBody('<app></app>');
|
||||
serverBootstrap(MyServerApp, [
|
||||
BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS
|
||||
]).then(() => { expect(getDOM().getText(body)).toEqual('Works!'); });
|
||||
platformDynamicServer().bootstrapModule(ExampleModule).then(() => {
|
||||
expect(getDOM().getText(body)).toEqual('Works!');
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@Component({selector: 'app', template: `Works!`})
|
||||
class MyServerApp {
|
||||
}
|
||||
|
Reference in New Issue
Block a user