File tree Expand file tree Collapse file tree 5 files changed +25
-1
lines changed
packages/angular/build/src Expand file tree Collapse file tree 5 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,13 @@ interface InternalOptions {
9898 */
9999 externalRuntimeStyles ?: boolean ;
100100
101+ /**
102+ * Enables the AOT compiler to generate template component update functions.
103+ * This option is only intended to be used with a development server that can process and serve component
104+ * template updates.
105+ */
106+ templateUpdates ?: boolean ;
107+
101108 /**
102109 * Enables instrumentation to collect code coverage data for specific files.
103110 *
@@ -463,6 +470,7 @@ export async function normalizeOptions(
463470 externalRuntimeStyles,
464471 instrumentForCoverage,
465472 security,
473+ templateUpdates : ! ! options . templateUpdates ,
466474 } ;
467475}
468476
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ import {
2323 createRemoveIdPrefixPlugin ,
2424} from '../../tools/vite/plugins' ;
2525import { loadProxyConfiguration , normalizeSourceMaps } from '../../utils' ;
26- import { useComponentStyleHmr } from '../../utils/environment-options' ;
26+ import { useComponentStyleHmr , useComponentTemplateHmr } from '../../utils/environment-options' ;
2727import { loadEsmModule } from '../../utils/load-esm' ;
2828import { Result , ResultFile , ResultKind } from '../application/results' ;
2929import {
@@ -145,6 +145,14 @@ export async function* serveWithVite(
145145 void loadEsmModule ( '@angular/compiler' ) ;
146146 }
147147
148+ // Enable to support component template hot replacement (`NG_HMR_TEMPLATE=1` can be used to enable)
149+ browserOptions . templateUpdates = ! ! serverOptions . liveReload && useComponentTemplateHmr ;
150+ if ( browserOptions . templateUpdates ) {
151+ context . logger . warn (
152+ 'Experimental support for component template hot replacement has been enabled via the "NG_HMR_TEMPLATE" environment variable.' ,
153+ ) ;
154+ }
155+
148156 // Setup the prebundling transformer that will be shared across Vite prebundling requests
149157 const prebundleTransformer = new JavaScriptTransformer (
150158 // Always enable JIT linking to support applications built with and without AOT.
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export interface CompilerPluginOptions {
5151 incremental : boolean ;
5252 externalRuntimeStyles ?: boolean ;
5353 instrumentForCoverage ?: ( request : string ) => boolean ;
54+ templateUpdates ?: boolean ;
5455}
5556
5657// eslint-disable-next-line max-lines-per-function
@@ -656,6 +657,7 @@ function createCompilerOptionsTransformer(
656657 sourceRoot : undefined ,
657658 preserveSymlinks,
658659 externalRuntimeStyles : pluginOptions . externalRuntimeStyles ,
660+ _enableHmr : pluginOptions . templateUpdates ,
659661 } ;
660662 } ;
661663}
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export function createCompilerPluginOptions(
2525 jit,
2626 externalRuntimeStyles,
2727 instrumentForCoverage,
28+ templateUpdates,
2829 } = options ;
2930 const incremental = ! ! options . watch ;
3031
@@ -40,5 +41,6 @@ export function createCompilerPluginOptions(
4041 incremental,
4142 externalRuntimeStyles,
4243 instrumentForCoverage,
44+ templateUpdates,
4345 } ;
4446}
Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ const hmrComponentStylesVariable = process.env['NG_HMR_CSTYLES'];
105105export const useComponentStyleHmr =
106106 ! isPresent ( hmrComponentStylesVariable ) || ! isDisabled ( hmrComponentStylesVariable ) ;
107107
108+ const hmrComponentTemplateVariable = process . env [ 'NG_HMR_TEMPLATES' ] ;
109+ export const useComponentTemplateHmr =
110+ isPresent ( hmrComponentTemplateVariable ) && isEnabled ( hmrComponentTemplateVariable ) ;
111+
108112const partialSsrBuildVariable = process . env [ 'NG_BUILD_PARTIAL_SSR' ] ;
109113export const usePartialSsrBuild =
110114 isPresent ( partialSsrBuildVariable ) && isEnabled ( partialSsrBuildVariable ) ;
You can’t perform that action at this time.
0 commit comments