Skip to content

feat(@angular-devkit/build-angular): support web workers in karma bui… #14122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions packages/angular/cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@
"type": "null",
"definitions": {
"appShell": {
"description": "App Shell target options for Build Facade.",
"description": "App Shell target options for Architect.",
"type": "object",
"properties": {
"browserTarget": {
Expand Down Expand Up @@ -580,7 +580,7 @@
"additionalProperties": false
},
"browser": {
"title": "Webpack browser schema for Build Facade.",
"title": "Webpack browser schema for Architect.",
"description": "Browser target options",
"properties": {
"assets": {
Expand Down Expand Up @@ -1050,7 +1050,7 @@
}
},
"devServer": {
"description": "Dev Server target options for Build Facade.",
"description": "Dev Server target options for Architect.",
"type": "object",
"properties": {
"browserTarget": {
Expand Down Expand Up @@ -1223,7 +1223,7 @@
"additionalProperties": false
},
"extracti18n": {
"description": "Extract i18n target options for Build Facade.",
"description": "Extract i18n target options for Architect.",
"type": "object",
"properties": {
"browserTarget": {
Expand Down Expand Up @@ -1264,7 +1264,7 @@
"additionalProperties": false
},
"karma": {
"description": "Karma target options for Build Facade.",
"description": "Karma target options for Architect.",
"type": "object",
"properties": {
"main": {
Expand Down Expand Up @@ -1439,6 +1439,10 @@
"items": {
"type": "string"
}
},
"webWorkerTsConfig": {
"type": "string",
"description": "TypeScript configuration for Web Worker modules."
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -1514,7 +1518,7 @@
}
},
"protractor": {
"description": "Protractor target options for Build Facade.",
"description": "Protractor target options for Architect.",
"type": "object",
"properties": {
"protractorConfig": {
Expand Down Expand Up @@ -1822,7 +1826,7 @@
}
},
"tslint": {
"description": "TSlint target options for Build Facade.",
"description": "TSlint target options for Architect.",
"type": "object",
"properties": {
"tslintConfig": {
Expand Down
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 @@ -16,6 +16,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),
],
host,
);
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