From ba9c755f33d5a7c247aade6ca7a1e90a1fada084 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 11 Dec 2020 20:05:17 +0100 Subject: [PATCH] fix(@angular-devkit/build-angular): add console error when using HMR in production mode FIx: #19591 --- .../build_angular/src/webpack/plugins/hmr/hmr-accept.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts b/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts index 9adfa4cad98c..10aee6b52427 100644 --- a/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts +++ b/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts @@ -7,7 +7,7 @@ */ // tslint:disable-next-line: no-implicit-dependencies -import { ApplicationRef, PlatformRef, Type, ɵresetCompiledComponents } from '@angular/core'; +import { ApplicationRef, PlatformRef, Type, isDevMode, ɵresetCompiledComponents } from '@angular/core'; import { filter, take } from 'rxjs/operators'; // For the time being we cannot use the DOM lib because it conflicts with @types/node, @@ -27,6 +27,12 @@ export default function (mod: any): void { return; } + if (!isDevMode()) { + console.error(`[NG HMR] Cannot use HMR when Angular is running in production mode. To prevent production mode, do not call 'enableProdMode()'.`); + + return; + } + mod['hot'].accept(); mod['hot'].dispose(() => { if (typeof ng === 'undefined') {