feat(platform-webworker): deprecate platform-webworker (#30642)

DEPRECATION:

platform-webworker has been around since the initial release of Angular
version 2. It began as an experiment to leverage Angular's rendering
architecture and try something different: to run an entire web application
in a web worker.

We've learned a lot from this experiment, and have come to the conclusion
that pushing entire applications to run in a web worker is not a recipe for
success for most applications. This is due to a number of unresolved issues,
including:

* Poor or non-existent support for web worker APIs in web crawlers/indexers.
* Poor support in build and bundling tooling.

As a result, as of Angular version 8, we are deprecating the
`platform-webworker` APIs in Angular. This consists of both NPM packages,
`@angular/platform-webworker` and `@angular/platform-webworker-dynamic`.

Going forward, we will focus our efforts related to web workers around their
primary use case of offloading CPU-intensive but not critical work.

FW-1339 #resolve

PR Close #30642
This commit is contained in:
Alex Rickabaugh 2019-05-23 12:39:20 -07:00 committed by Jason Aden
parent f310a5960e
commit ccc76f7498
15 changed files with 61 additions and 0 deletions

View File

@ -122,6 +122,19 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
| --- | ----------- | --------------------- | ----- |
| [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#queryParamsHandling) | v4 | none |
{@a platform-webworker}
### @angular/platform-webworker
| API | Replacement | Deprecation announced | Notes |
| --- | ----------- | --------------------- | ----- |
| [All entry points](api/platform-webworker) | none | v8 | See [platform-webworker](#webworker-apps). |
{@a platform-webworker-dynamic}
### @angular/platform-webworker-dynamic
| API | Replacement | Deprecation announced | Notes |
| --- | ----------- | --------------------- | ----- |
| [All entry points](api/platform-webworker-dynamic) | none | v8 | See [platform-webworker](#webworker-apps). |
{@a upgrade}
### @angular/upgrade
@ -380,6 +393,21 @@ Instead, use web workers primarily for offloading CPU intensive, but functionall
{@a webworker-apps}
### platform-webworker Angular applications
platform-webworker has been around since the initial release of Angular version 2. It began as an experiment to leverage Angular's rendering architecture and try something different: to run an entire web application in a web worker.
We've learned a lot from this experiment, and have come to the conclusion that pushing entire applications to run in a web worker is not a recipe for success for most applications. This is due to a number of unresolved issues, including:
* Poor or non-existent support for web worker APIs in web crawlers/indexers.
* Poor support in build and bundling tooling.
As a result, as of Angular version 8, we are deprecating the `platform-webworker` APIs in Angular. This consists of both NPM packages, `@angular/platform-webworker` and `@angular/platform-webworker-dynamic`.
Going forward, we will focus our efforts related to web workers around their primary use case of offloading CPU-intensive but not critical work.
{@a removed}
## Removed APIs

View File

@ -16,6 +16,7 @@ export {VERSION} from './version';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const platformWorkerAppDynamic =
createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [

View File

@ -16,5 +16,6 @@ import {Version} from '@angular/core';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const VERSION = new Version('0.0.0-PLACEHOLDER');

View File

@ -24,6 +24,7 @@ export {platformWorkerUi} from './worker_render';
* Bootstraps the worker ui.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export function bootstrapWorkerUi(
workerScriptUri: string, customProviders: StaticProvider[] = []): Promise<PlatformRef> {

View File

@ -16,5 +16,6 @@ import {Version} from '@angular/core';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const VERSION = new Version('0.0.0-PLACEHOLDER');

View File

@ -12,6 +12,7 @@ import {Serializer, SerializerTypes} from './serializer';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
@Injectable()
export class ClientMessageBrokerFactory {
@ -39,6 +40,7 @@ interface PromiseCompleter {
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export class ClientMessageBroker {
private _pending = new Map<string, PromiseCompleter>();

View File

@ -17,6 +17,7 @@ import {EventEmitter, NgZone} from '@angular/core';
* by the corresponding MessageBusSource.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export abstract class MessageBus implements MessageBusSource, MessageBusSink {
/**

View File

@ -12,6 +12,7 @@ import {RenderStore} from './render_store';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const enum SerializerTypes {
// RendererType2

View File

@ -13,6 +13,7 @@ import {Serializer, SerializerTypes} from '../shared/serializer';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
@Injectable()
export class ServiceMessageBrokerFactory {
@ -40,6 +41,7 @@ export class ServiceMessageBrokerFactory {
* If that method returns a promise, the UIMessageBroker returns the result to the worker.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export class ServiceMessageBroker {
private _sink: EventEmitter<any>;
@ -91,6 +93,7 @@ export class ServiceMessageBroker {
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export interface ReceivedMessage {
method: string;

View File

@ -22,6 +22,7 @@ import {MessageBasedPlatformLocation} from './platform_location';
* A list of {@link Provider}s. To use the router in a Worker enabled application you must
* include these providers when setting up the render thread.
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const WORKER_UI_LOCATION_PROVIDERS = <StaticProvider[]>[
{provide: MessageBasedPlatformLocation, deps: [ServiceMessageBrokerFactory,

View File

@ -17,6 +17,7 @@ import {WebWorkerPlatformLocation} from './platform_location';
* a worker context.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const WORKER_APP_LOCATION_PROVIDERS = [
{provide: PlatformLocation, useClass: WebWorkerPlatformLocation}, {

View File

@ -24,6 +24,7 @@ import {WorkerDomAdapter} from './web_workers/worker/worker_adapter';
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const platformWorkerApp = createPlatformFactory(
platformCore, 'workerApp', [{provide: PLATFORM_ID, useValue: PLATFORM_WORKER_APP_ID}]);
@ -56,6 +57,7 @@ export function setupWebWorker(): void {
* The ng module for the worker app side.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
@NgModule({
providers: [

View File

@ -26,6 +26,7 @@ import {MessageBasedRenderer2} from './web_workers/ui/renderer';
* and underlying {@link MessageBus} for lower level message passing.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
@Injectable()
export class WebWorkerInstance {
@ -43,6 +44,7 @@ export class WebWorkerInstance {
/**
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
@ -51,6 +53,7 @@ export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
* created.
*
* @publicApi
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
*/
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');

View File

@ -1,3 +1,5 @@
/** @deprecated */
export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
/** @deprecated */
export declare const VERSION: Version;

View File

@ -1,9 +1,12 @@
/** @deprecated */
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise<PlatformRef>;
/** @deprecated */
export declare class ClientMessageBroker {
runOnService(args: UiArguments, returnType: Type<any> | SerializerTypes | null): Promise<any> | null;
}
/** @deprecated */
export declare class ClientMessageBrokerFactory {
createMessageBroker(channel: string, runInZone?: boolean): ClientMessageBroker;
}
@ -14,6 +17,7 @@ export declare class FnArg {
constructor(value: any, type?: Type<any> | SerializerTypes);
}
/** @deprecated */
export declare abstract class MessageBus implements MessageBusSource, MessageBusSink {
abstract attachToZone(zone: NgZone): void;
abstract from(channel: string): EventEmitter<any>;
@ -33,10 +37,12 @@ export interface MessageBusSource {
initChannel(channel: string, runInZone: boolean): void;
}
/** @deprecated */
export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
/** @deprecated */
export interface ReceivedMessage {
args: any[];
id: string;
@ -44,16 +50,19 @@ export interface ReceivedMessage {
type: string;
}
/** @deprecated */
export declare const enum SerializerTypes {
RENDERER_TYPE_2 = 0,
PRIMITIVE = 1,
RENDER_STORE_OBJECT = 2
}
/** @deprecated */
export declare class ServiceMessageBroker {
registerMethod(methodName: string, signature: Array<Type<any> | SerializerTypes> | null, method: (..._: any[]) => Promise<any> | void, returnType?: Type<any> | SerializerTypes): void;
}
/** @deprecated */
export declare class ServiceMessageBrokerFactory {
createMessageBroker(channel: string, runInZone?: boolean): ServiceMessageBroker;
}
@ -64,8 +73,10 @@ export declare class UiArguments {
constructor(method: string, args?: FnArg[] | undefined);
}
/** @deprecated */
export declare const VERSION: Version;
/** @deprecated */
export declare const WORKER_APP_LOCATION_PROVIDERS: ({
provide: typeof PlatformLocation;
useClass: typeof WebWorkerPlatformLocation;
@ -86,7 +97,9 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({
multi?: undefined;
})[];
/** @deprecated */
export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[];
/** @deprecated */
export declare class WorkerAppModule {
}