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:
parent
f310a5960e
commit
ccc76f7498
|
@ -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 |
|
| [`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}
|
{@a upgrade}
|
||||||
### @angular/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}
|
{@a removed}
|
||||||
## Removed APIs
|
## Removed APIs
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ export {VERSION} from './version';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const platformWorkerAppDynamic =
|
export const platformWorkerAppDynamic =
|
||||||
createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [
|
createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [
|
||||||
|
|
|
@ -16,5 +16,6 @@ import {Version} from '@angular/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const VERSION = new Version('0.0.0-PLACEHOLDER');
|
export const VERSION = new Version('0.0.0-PLACEHOLDER');
|
||||||
|
|
|
@ -24,6 +24,7 @@ export {platformWorkerUi} from './worker_render';
|
||||||
* Bootstraps the worker ui.
|
* Bootstraps the worker ui.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export function bootstrapWorkerUi(
|
export function bootstrapWorkerUi(
|
||||||
workerScriptUri: string, customProviders: StaticProvider[] = []): Promise<PlatformRef> {
|
workerScriptUri: string, customProviders: StaticProvider[] = []): Promise<PlatformRef> {
|
||||||
|
|
|
@ -16,5 +16,6 @@ import {Version} from '@angular/core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const VERSION = new Version('0.0.0-PLACEHOLDER');
|
export const VERSION = new Version('0.0.0-PLACEHOLDER');
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {Serializer, SerializerTypes} from './serializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ClientMessageBrokerFactory {
|
export class ClientMessageBrokerFactory {
|
||||||
|
@ -39,6 +40,7 @@ interface PromiseCompleter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export class ClientMessageBroker {
|
export class ClientMessageBroker {
|
||||||
private _pending = new Map<string, PromiseCompleter>();
|
private _pending = new Map<string, PromiseCompleter>();
|
||||||
|
|
|
@ -17,6 +17,7 @@ import {EventEmitter, NgZone} from '@angular/core';
|
||||||
* by the corresponding MessageBusSource.
|
* by the corresponding MessageBusSource.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export abstract class MessageBus implements MessageBusSource, MessageBusSink {
|
export abstract class MessageBus implements MessageBusSource, MessageBusSink {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {RenderStore} from './render_store';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const enum SerializerTypes {
|
export const enum SerializerTypes {
|
||||||
// RendererType2
|
// RendererType2
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {Serializer, SerializerTypes} from '../shared/serializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ServiceMessageBrokerFactory {
|
export class ServiceMessageBrokerFactory {
|
||||||
|
@ -40,6 +41,7 @@ export class ServiceMessageBrokerFactory {
|
||||||
* If that method returns a promise, the UIMessageBroker returns the result to the worker.
|
* If that method returns a promise, the UIMessageBroker returns the result to the worker.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export class ServiceMessageBroker {
|
export class ServiceMessageBroker {
|
||||||
private _sink: EventEmitter<any>;
|
private _sink: EventEmitter<any>;
|
||||||
|
@ -91,6 +93,7 @@ export class ServiceMessageBroker {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export interface ReceivedMessage {
|
export interface ReceivedMessage {
|
||||||
method: string;
|
method: string;
|
||||||
|
|
|
@ -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
|
* 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.
|
* include these providers when setting up the render thread.
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const WORKER_UI_LOCATION_PROVIDERS = <StaticProvider[]>[
|
export const WORKER_UI_LOCATION_PROVIDERS = <StaticProvider[]>[
|
||||||
{provide: MessageBasedPlatformLocation, deps: [ServiceMessageBrokerFactory,
|
{provide: MessageBasedPlatformLocation, deps: [ServiceMessageBrokerFactory,
|
||||||
|
|
|
@ -17,6 +17,7 @@ import {WebWorkerPlatformLocation} from './platform_location';
|
||||||
* a worker context.
|
* a worker context.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const WORKER_APP_LOCATION_PROVIDERS = [
|
export const WORKER_APP_LOCATION_PROVIDERS = [
|
||||||
{provide: PlatformLocation, useClass: WebWorkerPlatformLocation}, {
|
{provide: PlatformLocation, useClass: WebWorkerPlatformLocation}, {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {WorkerDomAdapter} from './web_workers/worker/worker_adapter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const platformWorkerApp = createPlatformFactory(
|
export const platformWorkerApp = createPlatformFactory(
|
||||||
platformCore, 'workerApp', [{provide: PLATFORM_ID, useValue: PLATFORM_WORKER_APP_ID}]);
|
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.
|
* The ng module for the worker app side.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
@NgModule({
|
@NgModule({
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -26,6 +26,7 @@ import {MessageBasedRenderer2} from './web_workers/ui/renderer';
|
||||||
* and underlying {@link MessageBus} for lower level message passing.
|
* and underlying {@link MessageBus} for lower level message passing.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class WebWorkerInstance {
|
export class WebWorkerInstance {
|
||||||
|
@ -43,6 +44,7 @@ export class WebWorkerInstance {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
|
export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
|
||||||
|
|
||||||
|
@ -51,6 +53,7 @@ export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
|
||||||
* created.
|
* created.
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
|
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
|
||||||
*/
|
*/
|
||||||
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
||||||
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');
|
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/** @deprecated */
|
||||||
export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare const VERSION: Version;
|
export declare const VERSION: Version;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
/** @deprecated */
|
||||||
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise<PlatformRef>;
|
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise<PlatformRef>;
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare class ClientMessageBroker {
|
export declare class ClientMessageBroker {
|
||||||
runOnService(args: UiArguments, returnType: Type<any> | SerializerTypes | null): Promise<any> | null;
|
runOnService(args: UiArguments, returnType: Type<any> | SerializerTypes | null): Promise<any> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare class ClientMessageBrokerFactory {
|
export declare class ClientMessageBrokerFactory {
|
||||||
createMessageBroker(channel: string, runInZone?: boolean): ClientMessageBroker;
|
createMessageBroker(channel: string, runInZone?: boolean): ClientMessageBroker;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +17,7 @@ export declare class FnArg {
|
||||||
constructor(value: any, type?: Type<any> | SerializerTypes);
|
constructor(value: any, type?: Type<any> | SerializerTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare abstract class MessageBus implements MessageBusSource, MessageBusSink {
|
export declare abstract class MessageBus implements MessageBusSource, MessageBusSink {
|
||||||
abstract attachToZone(zone: NgZone): void;
|
abstract attachToZone(zone: NgZone): void;
|
||||||
abstract from(channel: string): EventEmitter<any>;
|
abstract from(channel: string): EventEmitter<any>;
|
||||||
|
@ -33,10 +37,12 @@ export interface MessageBusSource {
|
||||||
initChannel(channel: string, runInZone: boolean): void;
|
initChannel(channel: string, runInZone: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export interface ReceivedMessage {
|
export interface ReceivedMessage {
|
||||||
args: any[];
|
args: any[];
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -44,16 +50,19 @@ export interface ReceivedMessage {
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare const enum SerializerTypes {
|
export declare const enum SerializerTypes {
|
||||||
RENDERER_TYPE_2 = 0,
|
RENDERER_TYPE_2 = 0,
|
||||||
PRIMITIVE = 1,
|
PRIMITIVE = 1,
|
||||||
RENDER_STORE_OBJECT = 2
|
RENDER_STORE_OBJECT = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare class ServiceMessageBroker {
|
export declare class ServiceMessageBroker {
|
||||||
registerMethod(methodName: string, signature: Array<Type<any> | SerializerTypes> | null, method: (..._: any[]) => Promise<any> | void, returnType?: Type<any> | SerializerTypes): void;
|
registerMethod(methodName: string, signature: Array<Type<any> | SerializerTypes> | null, method: (..._: any[]) => Promise<any> | void, returnType?: Type<any> | SerializerTypes): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare class ServiceMessageBrokerFactory {
|
export declare class ServiceMessageBrokerFactory {
|
||||||
createMessageBroker(channel: string, runInZone?: boolean): ServiceMessageBroker;
|
createMessageBroker(channel: string, runInZone?: boolean): ServiceMessageBroker;
|
||||||
}
|
}
|
||||||
|
@ -64,8 +73,10 @@ export declare class UiArguments {
|
||||||
constructor(method: string, args?: FnArg[] | undefined);
|
constructor(method: string, args?: FnArg[] | undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare const VERSION: Version;
|
export declare const VERSION: Version;
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare const WORKER_APP_LOCATION_PROVIDERS: ({
|
export declare const WORKER_APP_LOCATION_PROVIDERS: ({
|
||||||
provide: typeof PlatformLocation;
|
provide: typeof PlatformLocation;
|
||||||
useClass: typeof WebWorkerPlatformLocation;
|
useClass: typeof WebWorkerPlatformLocation;
|
||||||
|
@ -86,7 +97,9 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({
|
||||||
multi?: undefined;
|
multi?: undefined;
|
||||||
})[];
|
})[];
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[];
|
export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[];
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export declare class WorkerAppModule {
|
export declare class WorkerAppModule {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue