@@ -655,8 +655,10 @@ export async function projectResolveBrand(
655655 }
656656}
657657
658- // Create a class that extends Map and implements Cloneable
659- // All operations normalize keys for cross-platform consistency
658+ // A Map that normalizes path keys for cross-platform consistency.
659+ // All path operations normalize keys (forward slashes, lowercase on Windows).
660+ // Implements Cloneable but shares state intentionally - in preview mode,
661+ // the project context is reused across renders and cache state must persist.
660662export class FileInformationCacheMap extends Map < string , FileInformation >
661663 implements Cloneable < Map < string , FileInformation > > {
662664 override get ( key : string ) : FileInformation | undefined {
@@ -675,8 +677,14 @@ export class FileInformationCacheMap extends Map<string, FileInformation>
675677 return super . delete ( normalizePath ( key ) ) ;
676678 }
677679
680+ // Note: Iterator methods (keys(), entries(), forEach(), [Symbol.iterator])
681+ // return normalized keys as stored. Code iterating over the cache sees
682+ // normalized paths, which is consistent with how keys are stored.
683+
684+ // Returns this instance (shared reference) rather than a copy.
685+ // This is intentional: in preview mode, project context is cloned for
686+ // each render but the cache must be shared so invalidations persist.
678687 clone ( ) : Map < string , FileInformation > {
679- // Return the same instance (reference) instead of creating a clone
680688 return this ;
681689 }
682690}
0 commit comments