Skip to content
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

fix(@schematics/angular): added webWorkerTsConfig into test options #21057

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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