Skip to content

Commit 153de34

Browse files
Brooooooklynclaude
andcommitted
fix: keep SSR resource watchers for cache invalidation
The fs.watch callback serves dual purpose: (1) invalidating resourceCache on file change, and (2) sending HMR WebSocket events. The HMR part is already independently gated by componentIds, which are only populated for client transforms. Skipping watcher registration for SSR would leave resourceCache stale when external templates/styles change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fe93bae commit 153de34

File tree

1 file changed

+6
-2
lines changed
  • napi/angular-compiler/vite-plugin

1 file changed

+6
-2
lines changed

napi/angular-compiler/vite-plugin/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,14 @@ export function angular(options: PluginOptions = {}): Plugin[] {
472472
// bundles (see @angular/build application-code-bundle.js).
473473
const isSSR = !!options?.ssr
474474

475-
// Track dependencies for HMR (client-side only)
475+
// Track dependencies for resource cache invalidation and HMR.
476476
// DON'T use addWatchFile - it creates modules in Vite's graph!
477477
// Instead, use our custom watcher that doesn't create modules.
478-
if (watchMode && viteServer && !isSSR) {
478+
// Note: watchers are registered for both client AND SSR transforms
479+
// because the fs.watch callback invalidates resourceCache (needed by
480+
// both). The HMR-specific behavior inside the callback is separately
481+
// gated by componentIds, which are only populated for client transforms.
482+
if (watchMode && viteServer) {
479483
const watchFn = (viteServer as any).__angularWatchTemplate
480484
for (const dep of dependencies) {
481485
const normalizedDep = normalizePath(dep)

0 commit comments

Comments
 (0)