Skip to content

Commit

Permalink
fix(@angular/build): use component updates for component style HMR
Browse files Browse the repository at this point in the history
The newly stable template HMR support has also been improved to support hot
replacement of component stylesheets. While this is not as fast during a rebuild
as external stylesheet based HMR, it does currently avoid some edge cases with
the current implementation. Once these cases are resolved, the default may
be reverted to the previous setup.

If the previous behavior is preferred, the `NG_HMR_CSTYLES=1` environment
variable can be used.

(cherry picked from commit ba51e72)
  • Loading branch information
clydin committed Jan 9, 2025
1 parent 8aa1ce6 commit e74300a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export async function* serveWithVite(
process.setSourceMapsEnabled(true);
}

// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
browserOptions.externalRuntimeStyles =
serverOptions.liveReload && serverOptions.hmr && useComponentStyleHmr;

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/utils/environment-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const shouldOptimizeChunks =

const hmrComponentStylesVariable = process.env['NG_HMR_CSTYLES'];
export const useComponentStyleHmr =
!isPresent(hmrComponentStylesVariable) || !isDisabled(hmrComponentStylesVariable);
isPresent(hmrComponentStylesVariable) && isEnabled(hmrComponentStylesVariable);

const hmrComponentTemplateVariable = process.env['NG_HMR_TEMPLATES'];
export const useComponentTemplateHmr =
Expand Down

0 comments on commit e74300a

Please sign in to comment.