Uh oh!
There was an error while loading. Please reload this page.
fix(@angular/build): retain watch files on error in load result cache - #33752
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the MemoryLoadResultCache to preserve and track previous watch files when caching build results that contain errors, ensuring that file dependencies are still watched and rebuilt correctly after a build failure. It also adds comprehensive tests for this behavior and updates the stylesheet plugin factory to include watchFiles in error results. The review feedback suggests copying the watchFiles array to prevent side effects from subsequent mutations and avoiding duplicate entries in the watchFiles array when the error file is the same as the entry filename.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
During incremental builds (serve and build --watch), caching an error result that lacks watch files would cause previously tracked dependency files to be dropped from the file watcher dependency map. For PostCSS plugins that read external dependency files (such as Tailwind configs or theme files), a syntax or parse error in a dependency file would result in an error being cached without watch files, preventing any subsequent edits to the dependency file from clearing the error until the entry stylesheet itself was modified. This commit improves MemoryLoadResultCache to remember the last-known watch set for each cache key across invalidations and union it into any newly cached error result. Additionally, compileString() in stylesheet-plugin-factory now explicitly returns error.file in watchFiles when catching a PostCSS CssSyntaxError, mirroring Sass and Less behavior. Closesangular#33666
b08a6c0 to
866184cCompareUh oh!
There was an error while loading. Please reload this page.
During incremental builds (serve and build --watch), caching an error result that lacks watch files would cause previously tracked dependency files to be dropped from the file watcher dependency map. For PostCSS plugins that read external dependency files (such as Tailwind configs or theme files), a syntax or parse error in a dependency file would result in an error being cached without watch files, preventing any subsequent edits to the dependency file from clearing the error until the entry stylesheet itself was modified.
This commit improves MemoryLoadResultCache to remember the last-known watch set for each cache key across invalidations and union it into any newly cached error result. Additionally, compileString() in stylesheet-plugin-factory now explicitly returns error.file in watchFiles when catching a PostCSS CssSyntaxError, mirroring Sass and Less behavior.
Closes#33666