Skip to content

Commit 323c883

Browse files
filipesilvaalexeagle
authored andcommitted
feat(@angular-devkit/build-angular): support web workers in karma builder
Followup to #13700, the karma builder did not get the same support but it should.
1 parent 609acf4 commit 323c883

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ const WorkerPlugin = require('worker-plugin');
1515

1616
export function getWorkerConfig(wco: WebpackConfigOptions): Configuration {
1717
const { buildOptions } = wco;
18+
1819
if (!buildOptions.webWorkerTsConfig) {
20+
return {};
21+
}
22+
23+
if (typeof buildOptions.webWorkerTsConfig != 'string') {
1924
throw new Error('The `webWorkerTsConfig` must be a string.');
2025
}
2126

packages/angular_devkit/build_angular/src/browser/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export function buildWebpackConfig(
155155
getBrowserConfig(wco),
156156
getStylesConfig(wco),
157157
getStatsConfig(wco),
158+
getWorkerConfig(wco),
158159
];
159160

160161
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
@@ -179,10 +180,6 @@ export function buildWebpackConfig(
179180
});
180181
}
181182

182-
if (wco.buildOptions.webWorkerTsConfig) {
183-
webpackConfigs.push(getWorkerConfig(wco));
184-
}
185-
186183
const webpackConfig = webpackMerge(webpackConfigs);
187184

188185
if (options.profile || process.env['NG_BUILD_PROFILING']) {

packages/angular_devkit/build_angular/src/karma/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
getNonAotConfig,
1616
getStylesConfig,
1717
getTestConfig,
18+
getWorkerConfig,
1819
} from '../angular-cli-files/models/webpack-configs';
1920
import { Schema as BrowserBuilderOptions } from '../browser/schema';
2021
import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config';
@@ -44,6 +45,7 @@ async function initialize(
4445
getStylesConfig(wco),
4546
getNonAotConfig(wco),
4647
getTestConfig(wco),
48+
getWorkerConfig(wco),
4749
],
4850
);
4951

packages/angular_devkit/build_angular/src/karma/schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@
185185
"items": {
186186
"type": "string"
187187
}
188+
},
189+
"webWorkerTsConfig": {
190+
"type": "string",
191+
"description": "TypeScript configuration for Web Worker modules."
188192
}
189193
},
190194
"additionalProperties": false,

0 commit comments

Comments
 (0)