Skip to content

Commit 8bfdd3d

Browse files
committed
refactor(@angular/build): check that AOT is enabled in HMR logic
This commit refactors the HMR logic within `@angular/build` to explicitly check for AOT.
1 parent 2a23579 commit 8bfdd3d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,15 @@ export async function* serveWithVite(
158158
process.setSourceMapsEnabled(true);
159159
}
160160

161+
const componentsHmrCanBeUsed =
162+
browserOptions.aot && serverOptions.liveReload && serverOptions.hmr;
163+
161164
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
162-
browserOptions.externalRuntimeStyles =
163-
serverOptions.liveReload && serverOptions.hmr && useComponentStyleHmr;
165+
browserOptions.externalRuntimeStyles = componentsHmrCanBeUsed && useComponentStyleHmr;
164166

165167
// Enable to support component template hot replacement (`NG_HMR_TEMPLATE=0` can be used to disable selectively)
166168
// This will also replace file-based/inline styles as code if external runtime styles are not enabled.
167-
browserOptions.templateUpdates =
168-
serverOptions.liveReload && serverOptions.hmr && useComponentTemplateHmr;
169+
browserOptions.templateUpdates = componentsHmrCanBeUsed && useComponentTemplateHmr;
169170
browserOptions.incrementalResults = true;
170171

171172
// Setup the prebundling transformer that will be shared across Vite prebundling requests

0 commit comments

Comments
 (0)