Skip to content

Commit 1fc8282

Browse files
committed
fix(@angular/build): allow component HMR with a service worker
When the service worker option is enabled, each code update will cause the `ngsw.json` configuration file to change due to the different hashes of the updated output. This is problematic for component HMR usage with the development server since the full reload fallback logic would be triggered due to the changed `ngsw.json` file. To avoid this problem, the `ngsw.json` configuration file is now special cased within the fallback logic.
1 parent 717d7cb commit 1fc8282

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/angular/build/src/builders/application/build-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ function* emitOutputResults(
327327
if (needFile) {
328328
if (file.path.endsWith('.css')) {
329329
hasCssUpdates = true;
330-
} else if (!/(?:\.m?js|\.map)$/.test(file.path)) {
330+
} else if (!/(?:\.m?js|\.map)$/.test(file.path) && file.path !== 'ngsw.json') {
331331
// Updates to non-JS files must signal an update with the dev server
332+
// except the service worker configuration which is special cased.
332333
incrementalResult.background = false;
333334
}
334335

0 commit comments

Comments
 (0)