Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/angular/build/src/builders/application/build-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { BuilderContext } from '@angular-devkit/architect';
import { existsSync } from 'node:fs';
import path from 'node:path';
import { BuildOutputFileType } from '../../tools/esbuild/bundler-context';
import { BuildOutputFile, BuildOutputFileType } from '../../tools/esbuild/bundler-context';
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
import { shutdownSassWorkerPool } from '../../tools/esbuild/stylesheets/sass-language';
import { logMessages, withNoProgress, withSpinner } from '../../tools/esbuild/utils';
Expand Down Expand Up @@ -327,8 +327,7 @@ function* emitOutputResults(
if (needFile) {
if (file.path.endsWith('.css')) {
hasCssUpdates = true;
} else if (!/(?:\.m?js|\.map)$/.test(file.path)) {
// Updates to non-JS files must signal an update with the dev server
} else if (!canBackgroundUpdate(file)) {
incrementalResult.background = false;
}

Expand Down Expand Up @@ -422,3 +421,15 @@ function* emitOutputResults(
function isCssFilePath(filePath: string): boolean {
return /\.css(?:\.map)?$/i.test(filePath);
}

function canBackgroundUpdate(file: BuildOutputFile): boolean {
// Files in the output root are not served and do not affect the
// application available with the development server.
if (file.type === BuildOutputFileType.Root) {
return true;
}

// Updates to non-JS files must signal an update with the dev server
// except the service worker configuration which is special cased.
return /(?:\.m?js|\.map)$/.test(file.path) || file.path === 'ngsw.json';
}