File tree Expand file tree Collapse file tree 6 files changed +16
-11
lines changed
angular_devkit/build_angular/src/builders/dev-server
angular/build/src/builders/dev-server Expand file tree Collapse file tree 6 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -114,8 +114,8 @@ export async function normalizeOptions(
114114 open,
115115 verbose,
116116 watch,
117- liveReload,
118- hmr,
117+ liveReload : ! ! liveReload ,
118+ hmr : hmr ?? ! ! liveReload ,
119119 headers,
120120 workspaceRoot,
121121 projectRoot,
Original file line number Diff line number Diff line change 6767 },
6868 "hmr" : {
6969 "type" : " boolean" ,
70- "description" : " Enable hot module replacement." ,
71- "default" : false
70+ "description" : " Enable hot module replacement. Defaults to the value of 'liveReload'. Currently, only global and component stylesheets are supported."
7271 },
7372 "watch" : {
7473 "type" : " boolean" ,
Original file line number Diff line number Diff line change @@ -137,8 +137,9 @@ export async function* serveWithVite(
137137 process . setSourceMapsEnabled ( true ) ;
138138 }
139139
140- // Enable to support component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable)
141- browserOptions . externalRuntimeStyles = ! ! serverOptions . liveReload && useComponentStyleHmr ;
140+ // Enable to support component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
141+ browserOptions . externalRuntimeStyles =
142+ serverOptions . liveReload && serverOptions . hmr && useComponentStyleHmr ;
142143
143144 // Enable to support component template hot replacement (`NG_HMR_TEMPLATE=1` can be used to enable)
144145 browserOptions . templateUpdates = ! ! serverOptions . liveReload && useComponentTemplateHmr ;
@@ -466,7 +467,7 @@ async function handleUpdate(
466467 return ;
467468 }
468469
469- if ( serverOptions . liveReload || serverOptions . hmr ) {
470+ if ( serverOptions . hmr ) {
470471 if ( updatedFiles . every ( ( f ) => f . endsWith ( '.css' ) ) ) {
471472 const timestamp = Date . now ( ) ;
472473 server . ws . send ( {
Original file line number Diff line number Diff line change @@ -85,12 +85,15 @@ export function execute(
8585 ) ;
8686 }
8787
88+ // New build system defaults hmr option to the value of liveReload
89+ normalizedOptions . hmr ??= normalizedOptions . liveReload ;
90+
8891 return defer ( ( ) =>
8992 Promise . all ( [ import ( '@angular/build/private' ) , import ( '../browser-esbuild' ) ] ) ,
9093 ) . pipe (
9194 switchMap ( ( [ { serveWithVite, buildApplicationInternal } , { convertBrowserOptions } ] ) =>
9295 serveWithVite (
93- normalizedOptions ,
96+ normalizedOptions as typeof normalizedOptions & { hmr : boolean } ,
9497 builderName ,
9598 ( options , context , codePlugins ) => {
9699 return builderName === '@angular-devkit/build-angular:browser-esbuild'
@@ -124,6 +127,9 @@ export function execute(
124127 ) ;
125128 }
126129
130+ // Webpack based build systems default to false for hmr option
131+ normalizedOptions . hmr ??= false ;
132+
127133 // Use Webpack for all other browser targets
128134 return defer ( ( ) => import ( './webpack-server' ) ) . pipe (
129135 switchMap ( ( { serveWebpackBrowser } ) =>
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ export async function normalizeOptions(
116116 open,
117117 verbose,
118118 watch,
119- liveReload,
119+ liveReload : ! ! liveReload ,
120120 hmr,
121121 headers,
122122 workspaceRoot,
Original file line number Diff line number Diff line change 8484 },
8585 "hmr" : {
8686 "type" : " boolean" ,
87- "description" : " Enable hot module replacement." ,
88- "default" : false
87+ "description" : " Enable hot module replacement."
8988 },
9089 "watch" : {
9190 "type" : " boolean" ,
You can’t perform that action at this time.
0 commit comments