File tree Expand file tree Collapse file tree 4 files changed +15
-0
lines changed
angular-compiler/vite-plugin Expand file tree Collapse file tree 4 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -370,6 +370,13 @@ export function angular(options: PluginOptions = {}): Plugin[] {
370370 event : 'angular:component-update' ,
371371 data : eventData ,
372372 } )
373+
374+ // Invalidate Vite's module transform cache so that a full page reload
375+ // picks up the new template/style content instead of serving stale output.
376+ const mod = server . moduleGraph . getModuleById ( componentFile )
377+ if ( mod ) {
378+ server . moduleGraph . invalidateModule ( mod )
379+ }
373380 }
374381 }
375382 }
@@ -654,6 +661,14 @@ export function angular(options: PluginOptions = {}): Plugin[] {
654661 debugHmr ( 'componentIds keys: %O' , Array . from ( componentIds . keys ( ) ) )
655662
656663 if ( isComponent && hasComponentId ) {
664+ // If there's a pending HMR update for this component, the .ts module
665+ // was invalidated by our fs.watch handler (template/style change), not
666+ // by an actual .ts file edit. Skip the full reload — HMR handles it.
667+ if ( pendingHmrUpdates . has ( ctx . file ) ) {
668+ debugHmr ( 'skipping full reload — pending HMR update from template/style change' )
669+ return [ ]
670+ }
671+
657672 debugHmr ( 'triggering full reload for component file change' )
658673 // Component FILE changes require a full reload because:
659674 // - Class definition changes can't be hot-swapped safely
You can’t perform that action at this time.
0 commit comments