Skip to content

Commit af3b14c

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 86a86ea commit af3b14c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 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,6 +159,19 @@ export async function* serveWithVite(
158159
process.setSourceMapsEnabled(true);
159160
}
160161

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

0 commit comments

Comments
 (0)