Skip to content

fix(@schematics/angular): keep existing worker tsconfig when generating another web worker - #34633

Merged
dgp1130 merged 1 commit into
angular:mainfrom
thekhegay:fix-web-worker-existing-tsconfig
Nov 3, 2026
Merged

dgp1130 merged 1 commit into
angular:mainfrom
thekhegay:fix-web-worker-existing-tsconfig

Conversation

@thekhegay

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

Second ng g web-worker fails in any workspace from ng new, --force does not help. Repro on 22.3.0-next.4:

$ ng g web-worker first
CREATE src/app/first.worker.ts (157 bytes)
CREATE tsconfig.worker.json (334 bytes)
UPDATE angular.json (1945 bytes)
$ ng g web-worker second
A merge conflicted on path "/tsconfig.worker.json".

Schematic always merges its tsconfig.worker.json, which worked only while file on disk was same as template
Since 21.2.0 new workspaces have prettier and CLI formats generated files, so first worker already leaves file diferent from template. Manual edit in that file gives same error

What is the new behavior?

Config is shared by all workers of project, so schematic writes it only when file is missing and existing one stays as is

New spec fails on main with same error

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Until 82c438b schematic skipped config when webWorkerTsConfig was already set. I went with tree.exists over bringing that back, option can be set with file missing and file can exist without option

…ng another web worker

second `ng g web-worker` failed with `A merge conflicted on path "/tsconfig.worker.json"` in any workspace from `ng new` since 21.2.0, CLI formats first file with prettier and it no longer matches template
config is shared by all workers of project, so it is now written only when file is missing

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Angular web-worker schematic to check if tsconfig.worker.json already exists before creating it, ensuring that existing configurations are not overwritten when adding multiple web workers to a project. A corresponding unit test has been added to verify this behavior. There are no review comments, and I have no feedback to provide.

@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Nov 3, 2026
@dgp1130
dgp1130 merged commit af423fd into angular:main Nov 3, 2026
42 checks passed
@dgp1130

dgp1130 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @schematics/angular target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants