Skip to content

Commit

Permalink
feat(@angular-devkit/build-angular): support module web workers.
Browse files Browse the repository at this point in the history
Supports new Worker(...,{type:module}) using github.com/googlechromelabs/worker-plugin
  • Loading branch information
developit authored and mgechev committed Apr 2, 2019
1 parent c4f6f46 commit c630d5f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,11 @@
"ngswConfigPath": {
"type": "string",
"description": "Path to ngsw-config.json."
},
"autoBundleWorkerModules": {
"type": "boolean",
"description": "Automatically bundle new Worker('..', { type:'module' })",
"default": true
},
"skipAppShell": {
"type": "boolean",
Expand Down
3 changes: 2 additions & 1 deletion packages/angular_devkit/build_angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"webpack-dev-server": "3.2.1",
"webpack-merge": "4.2.1",
"webpack-sources": "1.3.0",
"webpack-subresource-integrity": "1.1.0-rc.6"
"webpack-subresource-integrity": "1.1.0-rc.6",
"worker-plugin": "3.1.0"
},
"devDependencies": {
"@angular/animations": "^8.0.0-beta.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface BuildOptions {
namedChunks?: boolean;
subresourceIntegrity?: boolean;
serviceWorker?: boolean;
autoBundleWorkerModules?: boolean;
skipAppShell?: boolean;
statsJson: boolean;
forkTypeChecker: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const WorkerPlugin = require('worker-plugin');


// tslint:disable-next-line:no-any
Expand Down Expand Up @@ -133,6 +134,11 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
});
}

if (buildOptions.autoBundleWorkerModules) {
const workerPluginInstance = new WorkerPlugin({ globalObject: false });
extraPlugins.push(workerPluginInstance);
}

// process asset entries
if (buildOptions.assets) {
const copyWebpackPluginPatterns = buildOptions.assets.map((asset: AssetPatternClass) => {
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9897,6 +9897,13 @@ worker-farm@^1.5.2:
dependencies:
errno "~0.1.7"

[email protected]:
version "3.1.0"
resolved "https://registry.yarnpkg.com/worker-plugin/-/worker-plugin-3.1.0.tgz#6311778f3514a87c273510ee3f809cc3fe161e6f"
integrity sha512-iQ9KTTmmN5fhfc2KMR7CcDblvcrg1QQ4pXymqZ3cRZF8L0890YLBcEqlIsGPdxoFwghyN8RA1pCEhCKuTF4Lkw==
dependencies:
loader-utils "^1.1.0"

wrap-ansi@^2.0.0:
version "2.1.0"
resolved "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
Expand Down

0 comments on commit c630d5f

Please sign in to comment.