Skip to content

Commit 7d52648

Browse files
developitfilipesilva
authored andcommitted
feat(@angular-devkit/build-angular): Automatically bundle module workers.
Supports new Worker(...,{type:module}) using github.com/googlechromelabs/worker-plugin
1 parent 33bade7 commit 7d52648

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

packages/angular/cli/lib/config/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,11 @@
835835
"ngswConfigPath": {
836836
"type": "string",
837837
"description": "Path to ngsw-config.json."
838+
},
839+
"autoBundleWorkerModules": {
840+
"type": "boolean",
841+
"description": "Automatically bundle new Worker('..', { type:'module' })",
842+
"default": true
838843
},
839844
"skipAppShell": {
840845
"type": "boolean",

packages/angular_devkit/build_angular/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"webpack-dev-server": "3.1.14",
5050
"webpack-merge": "4.2.1",
5151
"webpack-sources": "1.3.0",
52-
"webpack-subresource-integrity": "1.1.0-rc.6"
52+
"webpack-subresource-integrity": "1.1.0-rc.6",
53+
"worker-plugin": "^3.0.0"
5354
},
5455
"optionalDependencies": {
5556
"node-sass": "4.11.0"

packages/angular_devkit/build_angular/src/angular-cli-files/models/build-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface BuildOptions {
5454
namedChunks?: boolean;
5555
subresourceIntegrity?: boolean;
5656
serviceWorker?: boolean;
57+
autoBundleWorkerModules?: boolean;
5758
skipAppShell?: boolean;
5859
statsJson: boolean;
5960
forkTypeChecker: boolean;

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const ProgressPlugin = require('webpack/lib/ProgressPlugin');
2323
const CircularDependencyPlugin = require('circular-dependency-plugin');
2424
const TerserPlugin = require('terser-webpack-plugin');
2525
const StatsPlugin = require('stats-webpack-plugin');
26+
const WorkerPlugin = require('worker-plugin');
2627

2728

2829
// tslint:disable-next-line:no-any
@@ -128,6 +129,11 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
128129
});
129130
}
130131

132+
if (buildOptions.autoBundleWorkerModules) {
133+
const workerPluginInstance = new WorkerPlugin();
134+
extraPlugins.push(workerPluginInstance);
135+
}
136+
131137
// process asset entries
132138
if (buildOptions.assets) {
133139
const copyWebpackPluginPatterns = buildOptions.assets.map((asset: AssetPatternObject) => {

yarn.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6083,7 +6083,6 @@ loglevel@^1.4.1:
60836083

60846084
"long@git://github.com/dcodeIO/long.js.git#8181a6b50a2a230f0b2a1e4c4093f9b9d19c8b69":
60856085
version "4.0.1"
6086-
uid "8181a6b50a2a230f0b2a1e4c4093f9b9d19c8b69"
60876086
resolved "git://github.com/dcodeIO/long.js.git#8181a6b50a2a230f0b2a1e4c4093f9b9d19c8b69"
60886087

60896088
long@~3:
@@ -10719,6 +10718,13 @@ worker-farm@^1.5.2:
1071910718
dependencies:
1072010719
errno "~0.1.7"
1072110720

10721+
worker-plugin@^3.0.0:
10722+
version "3.0.0"
10723+
resolved "https://registry.yarnpkg.com/worker-plugin/-/worker-plugin-3.0.0.tgz#70a64e732b3bf575ad5981071bc5f010dadd6f95"
10724+
integrity sha512-iLcZBwR3TZO2A8s4S+VNzvuCvAHeZx84IR/zE8O89E+VBTTdn73cwDaUoCroftwtW1Qo0mMxYkJqwf0hyFwmeA==
10725+
dependencies:
10726+
loader-utils "^1.1.0"
10727+
1072210728
wrap-ansi@^2.0.0:
1072310729
version "2.1.0"
1072410730
resolved "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"

0 commit comments

Comments
 (0)