Skip to content

Commit 361f181

Browse files
alxhubjasonaden
authored andcommittedMay 23, 2019
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
1 parent b408445 commit 361f181

File tree

15 files changed

+61
-0
lines changed

15 files changed

+61
-0
lines changed
 

‎aio/content/guide/deprecations.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,19 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
122122
| --- | ----------- | --------------------- | ----- |
123123
| [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#queryParamsHandling) | v4 | none |
124124

125+
{@a platform-webworker}
126+
### @angular/platform-webworker
127+
128+
| API | Replacement | Deprecation announced | Notes |
129+
| --- | ----------- | --------------------- | ----- |
130+
| [All entry points](api/platform-webworker) | none | v8 | See [platform-webworker](#webworker-apps)|
131+
132+
{@a platform-webworker-dynamic}
133+
### @angular/platform-webworker-dynamic
134+
135+
| API | Replacement | Deprecation announced | Notes |
136+
| --- | ----------- | --------------------- | ----- |
137+
| [All entry points](api/platform-webworker-dynamic) | none | v8 | See [platform-webworker](#webworker-apps)|
125138

126139
{@a upgrade}
127140
### @angular/upgrade
@@ -380,6 +393,21 @@ Instead, use web workers primarily for offloading CPU intensive, but functionall
380393

381394

382395

396+
{@a webworker-apps}
397+
### platform-webworker Angular applications
398+
399+
400+
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.
401+
402+
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:
403+
404+
* Poor or non-existent support for web worker APIs in web crawlers/indexers.
405+
* Poor support in build and bundling tooling.
406+
407+
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`.
408+
409+
Going forward, we will focus our efforts related to web workers around their primary use case of offloading CPU-intensive but not critical work.
410+
383411
{@a removed}
384412
## Removed APIs
385413

‎packages/platform-webworker-dynamic/src/platform-webworker-dynamic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export {VERSION} from './version';
1616

1717
/**
1818
* @publicApi
19+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
1920
*/
2021
export const platformWorkerAppDynamic =
2122
createPlatformFactory(platformCoreDynamic, 'workerAppDynamic', [

‎packages/platform-webworker-dynamic/src/version.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ import {Version} from '@angular/core';
1616

1717
/**
1818
* @publicApi
19+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
1920
*/
2021
export const VERSION = new Version('0.0.0-PLACEHOLDER');

‎packages/platform-webworker/src/platform-webworker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export {platformWorkerUi} from './worker_render';
2424
* Bootstraps the worker ui.
2525
*
2626
* @publicApi
27+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
2728
*/
2829
export function bootstrapWorkerUi(
2930
workerScriptUri: string, customProviders: StaticProvider[] = []): Promise<PlatformRef> {

‎packages/platform-webworker/src/version.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ import {Version} from '@angular/core';
1616

1717
/**
1818
* @publicApi
19+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
1920
*/
2021
export const VERSION = new Version('0.0.0-PLACEHOLDER');

‎packages/platform-webworker/src/web_workers/shared/client_message_broker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {Serializer, SerializerTypes} from './serializer';
1212

1313
/**
1414
* @publicApi
15+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
1516
*/
1617
@Injectable()
1718
export class ClientMessageBrokerFactory {
@@ -39,6 +40,7 @@ interface PromiseCompleter {
3940

4041
/**
4142
* @publicApi
43+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
4244
*/
4345
export class ClientMessageBroker {
4446
private _pending = new Map<string, PromiseCompleter>();

‎packages/platform-webworker/src/web_workers/shared/message_bus.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {EventEmitter, NgZone} from '@angular/core';
1717
* by the corresponding MessageBusSource.
1818
*
1919
* @publicApi
20+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
2021
*/
2122
export abstract class MessageBus implements MessageBusSource, MessageBusSink {
2223
/**

‎packages/platform-webworker/src/web_workers/shared/serializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {RenderStore} from './render_store';
1212

1313
/**
1414
* @publicApi
15+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
1516
*/
1617
export const enum SerializerTypes {
1718
// RendererType2

‎packages/platform-webworker/src/web_workers/shared/service_message_broker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {Serializer, SerializerTypes} from '../shared/serializer';
1313

1414
/**
1515
* @publicApi
16+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
1617
*/
1718
@Injectable()
1819
export class ServiceMessageBrokerFactory {
@@ -40,6 +41,7 @@ export class ServiceMessageBrokerFactory {
4041
* If that method returns a promise, the UIMessageBroker returns the result to the worker.
4142
*
4243
* @publicApi
44+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
4345
*/
4446
export class ServiceMessageBroker {
4547
private _sink: EventEmitter<any>;
@@ -91,6 +93,7 @@ export class ServiceMessageBroker {
9193

9294
/**
9395
* @publicApi
96+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
9497
*/
9598
export interface ReceivedMessage {
9699
method: string;

‎packages/platform-webworker/src/web_workers/ui/location_providers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {MessageBasedPlatformLocation} from './platform_location';
2222
* A list of {@link Provider}s. To use the router in a Worker enabled application you must
2323
* include these providers when setting up the render thread.
2424
* @publicApi
25+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
2526
*/
2627
export const WORKER_UI_LOCATION_PROVIDERS = <StaticProvider[]>[
2728
{provide: MessageBasedPlatformLocation, deps: [ServiceMessageBrokerFactory,

‎packages/platform-webworker/src/web_workers/worker/location_providers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {WebWorkerPlatformLocation} from './platform_location';
1717
* a worker context.
1818
*
1919
* @publicApi
20+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
2021
*/
2122
export const WORKER_APP_LOCATION_PROVIDERS = [
2223
{provide: PlatformLocation, useClass: WebWorkerPlatformLocation}, {

‎packages/platform-webworker/src/worker_app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {WorkerDomAdapter} from './web_workers/worker/worker_adapter';
2424

2525
/**
2626
* @publicApi
27+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
2728
*/
2829
export const platformWorkerApp = createPlatformFactory(
2930
platformCore, 'workerApp', [{provide: PLATFORM_ID, useValue: PLATFORM_WORKER_APP_ID}]);
@@ -56,6 +57,7 @@ export function setupWebWorker(): void {
5657
* The ng module for the worker app side.
5758
*
5859
* @publicApi
60+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
5961
*/
6062
@NgModule({
6163
providers: [

‎packages/platform-webworker/src/worker_render.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {MessageBasedRenderer2} from './web_workers/ui/renderer';
2626
* and underlying {@link MessageBus} for lower level message passing.
2727
*
2828
* @publicApi
29+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
2930
*/
3031
@Injectable()
3132
export class WebWorkerInstance {
@@ -43,6 +44,7 @@ export class WebWorkerInstance {
4344

4445
/**
4546
* @publicApi
47+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
4648
*/
4749
export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
4850

@@ -51,6 +53,7 @@ export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
5153
* created.
5254
*
5355
* @publicApi
56+
* @deprecated platform-webworker is deprecated in Angular and will be removed in version 10
5457
*/
5558
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
5659
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @deprecated */
12
export declare const platformWorkerAppDynamic: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
23

4+
/** @deprecated */
35
export declare const VERSION: Version;

‎tools/public_api_guard/platform-webworker/platform-webworker.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
/** @deprecated */
12
export declare function bootstrapWorkerUi(workerScriptUri: string, customProviders?: StaticProvider[]): Promise<PlatformRef>;
23

4+
/** @deprecated */
35
export declare class ClientMessageBroker {
46
runOnService(args: UiArguments, returnType: Type<any> | SerializerTypes | null): Promise<any> | null;
57
}
68

9+
/** @deprecated */
710
export declare class ClientMessageBrokerFactory {
811
createMessageBroker(channel: string, runInZone?: boolean): ClientMessageBroker;
912
}
@@ -14,6 +17,7 @@ export declare class FnArg {
1417
constructor(value: any, type?: Type<any> | SerializerTypes);
1518
}
1619

20+
/** @deprecated */
1721
export declare abstract class MessageBus implements MessageBusSource, MessageBusSink {
1822
abstract attachToZone(zone: NgZone): void;
1923
abstract from(channel: string): EventEmitter<any>;
@@ -33,27 +37,32 @@ export interface MessageBusSource {
3337
initChannel(channel: string, runInZone: boolean): void;
3438
}
3539

40+
/** @deprecated */
3641
export declare const platformWorkerApp: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
3742

3843
export declare const platformWorkerUi: (extraProviders?: StaticProvider[] | undefined) => PlatformRef;
3944

45+
/** @deprecated */
4046
export interface ReceivedMessage {
4147
args: any[];
4248
id: string;
4349
method: string;
4450
type: string;
4551
}
4652

53+
/** @deprecated */
4754
export declare const enum SerializerTypes {
4855
RENDERER_TYPE_2 = 0,
4956
PRIMITIVE = 1,
5057
RENDER_STORE_OBJECT = 2
5158
}
5259

60+
/** @deprecated */
5361
export declare class ServiceMessageBroker {
5462
registerMethod(methodName: string, signature: Array<Type<any> | SerializerTypes> | null, method: (..._: any[]) => Promise<any> | void, returnType?: Type<any> | SerializerTypes): void;
5563
}
5664

65+
/** @deprecated */
5766
export declare class ServiceMessageBrokerFactory {
5867
createMessageBroker(channel: string, runInZone?: boolean): ServiceMessageBroker;
5968
}
@@ -64,8 +73,10 @@ export declare class UiArguments {
6473
constructor(method: string, args?: FnArg[] | undefined);
6574
}
6675

76+
/** @deprecated */
6777
export declare const VERSION: Version;
6878

79+
/** @deprecated */
6980
export declare const WORKER_APP_LOCATION_PROVIDERS: ({
7081
provide: typeof PlatformLocation;
7182
useClass: typeof WebWorkerPlatformLocation;
@@ -86,7 +97,9 @@ export declare const WORKER_APP_LOCATION_PROVIDERS: ({
8697
multi?: undefined;
8798
})[];
8899

100+
/** @deprecated */
89101
export declare const WORKER_UI_LOCATION_PROVIDERS: StaticProvider[];
90102

103+
/** @deprecated */
91104
export declare class WorkerAppModule {
92105
}

0 commit comments

Comments
 (0)
Please sign in to comment.