Skip to content

fix(@schematics/angular): migrate serviceWorker: true to a config path in use-application-builder - #34564

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
MeAkib:fix/use-application-builder-service-worker
Oct 28, 2026
Merged

alan-agius4 merged 2 commits into
angular:mainfrom
MeAkib:fix/use-application-builder-service-worker

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

The browser builder accepts serviceWorker: true without ngswConfigPath and falls back to <projectRoot>/ngsw-config.json, but the application builder only accepts a path or false. The migration kept true when ngswConfigPath was not set in the same options object, so the first ng build after migrating failed schema validation.

Replace true with the ngswConfigPath of the same options, then the one in the base options, then the browser builder default.

…ath in use-application-builder

The browser builder accepts `serviceWorker: true` without `ngswConfigPath` and falls back to
`<projectRoot>/ngsw-config.json`, but the application builder only accepts a path or `false`. The
migration kept `true` when `ngswConfigPath` was not set in the same options object, so the first
`ng build` after migrating failed schema validation.

Replace `true` with the `ngswConfigPath` of the same options, then the one in the base options,
then the browser builder default.

@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 migration to the application builder by resolving how the serviceWorker option is handled, replacing serviceWorker: true with the actual path to the configuration file. However, the current implementation contains an issue where the else block incorrectly overwrites options['serviceWorker'] with options['ngswConfigPath'] even when the service worker is disabled (i.e., false or undefined). This would mistakenly enable the service worker across all configurations, and it is recommended to remove the else block to ensure it remains disabled when intended.

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Oct 28, 2026
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 28, 2026
@alan-agius4
alan-agius4 merged commit 0da5863 into angular:main Oct 28, 2026
41 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

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

@MeAkib
MeAkib deleted the fix/use-application-builder-service-worker branch October 28, 2026 18:04
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.

2 participants