You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A templateUrl shared by two components only hot-updates one of them #445
Split out of a Codex review finding on #444. Pre-existing on main — not introduced by that PR.
Symptom
When two component .ts files declare the same external templateUrl, editing that template dispatches angular:component-update for only one of them. The other keeps rendering the old template.
Cause
resourceToComponent is single-valued, and the last transform wins:
// vite-plugin/index.ts:264-268// Reverse mapping: resource file path → component file path. Multi-component// files almost always use inline templates, so a single owner per resource is// sufficient in practice; if a templateUrl/styleUrl is shared across multiple// components in the same file, only one will receive the HMR event.constresourceToComponent=newMap<string,string>()...// :814resourceToComponent.set(normalizedDep,actualId)
Never both. Note the reload on main in middlewareMode does not rescue the other component — Vite re-serves its .ts from the transform cache with the old template inlined.
#444 partially mitigates this: addWatchFile gives the template an importer edge to both owners, so both .ts modules are invalidated and a user-initiated refresh now fixes the stale one. On main it stayed stale until its .ts was touched or the server restarted.
Suggested fix
Mirror the shape styleComponentOwners already uses for styles — the plugin has the pattern, templates just do not use it:
Activity
fix(vite): dispatch template HMR to every component file sharing a te…