Skip to content

Commit 841c5ae

Browse files
gkalpakdylhunn
authored andcommitted
build(docs-infra): ensure ngsw.json generation is correct and deterministic (#43686)
As explained in #43679, currently the generation of the `ngsw.json` SW manifest is non-deterministic and often incorrect. Until we can update to an `@angular/service-worker` version that includes the fix from PR #43679, we temporarily work-around the issue by re-generating the `ngsw.json` manifest after `ng build` using the `ngsw-config` binary exposed by `@angular/service-worker`. NOTE: This works around the issue, because the [FileSystem][1] class used by the `ngsw-config` binary happens to be synchronous (unlike the implementation provided by the Angular CLI), thus avoiding the race conditions described in #43679. [1]: https://github.com/angular/angular/blob/c721135e370b34c840756bcfb22c8119b4c8c452/packages/service-worker/cli/filesystem.ts#L15 PR Close #43686
1 parent 3d26a07 commit 841c5ae

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎aio/ngsw-config.template.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"/assets/js/*.js",
1515
"/*.css",
1616
"/*.js",
17+
"!/ngsw-worker.js",
18+
"!/safety-worker.js",
19+
"!/worker-basic.min.js"
1720
],
1821
"urls": [
1922
"https://fonts.googleapis.com/**",

‎aio/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"~~clean-generated": "node --eval \"require('shelljs').rm('-rf', 'src/generated')\"",
7575
"pre~~build": "node scripts/build-ngsw-config",
7676
"~~build": "ng build --configuration=stable",
77-
"post~~build": "yarn build-404-page",
77+
"post~~build": "yarn build-404-page && ngsw-config dist src/generated/ngsw-config.json",
7878
"~~light-server": "light-server --bind=localhost --historyindex=/index.html --no-reload"
7979
},
8080
"//engines-comment": "Keep this in sync with /package.json and /aio/tools/examples/shared/package.json",

0 commit comments

Comments
 (0)