Skip to content
Merged
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
15 changes: 13 additions & 2 deletions packages/schematics/angular/web-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ export default function (options: WebWorkerOptions): Rule {
if (!projectTarget) {
throw new Error(`Target is not defined for this project.`);
}
const projectTargetOptions = ((projectTarget.options ||
{}) as unknown) as BrowserBuilderOptions;
const projectTargetOptions = (projectTarget.options || {}) as unknown as BrowserBuilderOptions;

if (options.path === undefined) {
options.path = buildDefaultPath(project);
Expand All @@ -142,6 +141,18 @@ export default function (options: WebWorkerOptions): Rule {
projectTargetOptions.webWorkerTsConfig = workerConfigPath;
}

const projectTestTarget = project.targets.get('test');
if (projectTestTarget) {
const projectTestTargetOptions = (projectTestTarget.options ||
{}) as unknown as BrowserBuilderOptions;

const needWebWorkerConfig = !projectTestTargetOptions.webWorkerTsConfig;
if (needWebWorkerConfig) {
const workerConfigPath = join(normalize(root), 'tsconfig.worker.json');
projectTestTargetOptions.webWorkerTsConfig = workerConfigPath;
}
}

const templateSource = apply(url('./files/worker'), [
applyTemplates({ ...options, ...strings }),
move(parsedPath.path),
Expand Down