Skip to content

Commit 908347a

Browse files
committed
fix(@angular/build): emit a warning when outputHashing is set to all or bundles when HMR is enabled
These values are incompatible with HMR. Closes #30697
1 parent 3c38877 commit 908347a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/angular/build/src/builders/dev-server/vite-server.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { loadProxyConfiguration, normalizeSourceMaps } from '../../utils';
2828
import { useComponentStyleHmr, useComponentTemplateHmr } from '../../utils/environment-options';
2929
import { loadEsmModule } from '../../utils/load-esm';
3030
import { Result, ResultFile, ResultKind } from '../application/results';
31+
import { OutputHashing } from '../application/schema';
3132
import {
3233
type ApplicationBuilderInternalOptions,
3334
BuildOutputFileType,
@@ -158,8 +159,19 @@ export async function* serveWithVite(
158159
process.setSourceMapsEnabled(true);
159160
}
160161

161-
const componentsHmrCanBeUsed =
162-
browserOptions.aot && serverOptions.liveReload && serverOptions.hmr;
162+
let componentsHmrCanBeUsed = browserOptions.aot && serverOptions.liveReload && serverOptions.hmr;
163+
if (
164+
componentsHmrCanBeUsed &&
165+
(browserOptions.outputHashing === OutputHashing.All ||
166+
browserOptions.outputHashing === OutputHashing.Bundles)
167+
) {
168+
componentsHmrCanBeUsed = false;
169+
170+
context.logger.warn(
171+
`Hot Module Replacement (HMR) is disabled because the 'outputHashing' option is set to '${browserOptions.outputHashing}'. ` +
172+
'HMR is incompatible with this setting.',
173+
);
174+
}
163175

164176
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
165177
browserOptions.externalRuntimeStyles = componentsHmrCanBeUsed && useComponentStyleHmr;

0 commit comments

Comments
 (0)