Skip to content

feat(ngsw): per-locale ngsw.json when --localize is set (#148) - #182

Merged
lukekania merged 1 commit into
milestone/v0.11.0-builder-parityfrom
feat/ngsw-per-locale-manifests
May 22, 2026
Merged

feat(ngsw): per-locale ngsw.json when --localize is set (#148)#182
lukekania merged 1 commit into
milestone/v0.11.0-builder-parityfrom
feat/ngsw-per-locale-manifests

Conversation

@lukekania

Copy link
Copy Markdown
Owner

Summary

Closes #148.

A localized build (--localize) with serviceWorker: true previously skipped ngsw.json generation entirely, with the warning "per-locale manifests are not yet supported". Apps had to choose between i18n and PWA caching.

This change:

  • Moves the service-worker step to run after locale fan-out (fan_out_locales).
  • When --localize is set, emits one ngsw.json per <out_dir>/<locale>/ subdirectory — each locale subdir is its own PWA deploy root, matching @angular/service-worker's expectation of one manifest per deploy root.
  • Asset hashes are computed from each locale's own tree, so a translated bundle hashes differently per locale (correct cache invalidation). Manifest URLs are locale-root-relative (no /<locale>/ prefix).
  • The non-localized path is unchanged.
  • Drops the skip warning.

No ngsw.rs changes were needed: generate_manifest already walks a dist_dir and emits root-relative URLs, so it works correctly when handed a locale subdir.

Bumps version to 0.10.14.

Test plan

  • cargo test -p ngc-rs test_service_worker_pipeline — new test_service_worker_pipeline_localized_fixture plus the existing non-localized fixture pass
  • cargo test -p ngc-rs — full crate suite green
  • cargo clippy -p ngc-rs --bins --tests — no warnings
  • New test asserts: per-locale ngsw.json exists, URLs are deploy-root-relative, hashes match each locale's own bytes, and en/fr record different hashes for the translated bundle

Previously a localized build with serviceWorker enabled skipped ngsw.json
generation entirely, forcing apps to choose between i18n and PWA caching.

Move the service-worker step to run after locale fan-out and, when
--localize is in use, emit one ngsw.json per <out_dir>/<locale>/ deploy
root. Asset hashes are computed from each locale's own tree, so a
translated bundle hashes differently per locale — correct cache
invalidation. The non-localized path is unchanged.

Bump version to 0.10.14.
@lukekania
lukekania merged commit c53f183 into milestone/v0.11.0-builder-parity May 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant