Skip to content

Commit

Permalink
feat(@angular-devkit/build-angular): support web workers in karma bui…
Browse files Browse the repository at this point in the history
…lder

Followup to #13700, the karma builder did not get the same support but it should.
  • Loading branch information
filipesilva authored and alexeagle committed Apr 10, 2019
1 parent 609acf4 commit 323c883
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const WorkerPlugin = require('worker-plugin');

export function getWorkerConfig(wco: WebpackConfigOptions): Configuration {
const { buildOptions } = wco;

if (!buildOptions.webWorkerTsConfig) {
return {};
}

if (typeof buildOptions.webWorkerTsConfig != 'string') {
throw new Error('The `webWorkerTsConfig` must be a string.');
}

Expand Down
5 changes: 1 addition & 4 deletions packages/angular_devkit/build_angular/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export function buildWebpackConfig(
getBrowserConfig(wco),
getStylesConfig(wco),
getStatsConfig(wco),
getWorkerConfig(wco),
];

if (wco.buildOptions.main || wco.buildOptions.polyfills) {
Expand All @@ -179,10 +180,6 @@ export function buildWebpackConfig(
});
}

if (wco.buildOptions.webWorkerTsConfig) {
webpackConfigs.push(getWorkerConfig(wco));
}

const webpackConfig = webpackMerge(webpackConfigs);

if (options.profile || process.env['NG_BUILD_PROFILING']) {
Expand Down
2 changes: 2 additions & 0 deletions packages/angular_devkit/build_angular/src/karma/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getNonAotConfig,
getStylesConfig,
getTestConfig,
getWorkerConfig,
} from '../angular-cli-files/models/webpack-configs';
import { Schema as BrowserBuilderOptions } from '../browser/schema';
import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config';
Expand Down Expand Up @@ -44,6 +45,7 @@ async function initialize(
getStylesConfig(wco),
getNonAotConfig(wco),
getTestConfig(wco),
getWorkerConfig(wco),
],
);

Expand Down
4 changes: 4 additions & 0 deletions packages/angular_devkit/build_angular/src/karma/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
"items": {
"type": "string"
}
},
"webWorkerTsConfig": {
"type": "string",
"description": "TypeScript configuration for Web Worker modules."
}
},
"additionalProperties": false,
Expand Down

0 comments on commit 323c883

Please sign in to comment.