Repository navigation
fix(@angular/build): keep Vite server file watcher disabled in Vitest watch mode - #34319
Conversation
… watch mode
In Vitest 5, the internal `vitest:config:append` plugin uses a post
`configResolved` hook that resets `server.watch` to `{}` when watch mode
is enabled (`server.watch ??= {}`), overriding the `server: { watch: null }`
setting passed in `vitestServerConfig`. This caused Vite to start a
duplicate Chokidar file watcher alongside the Angular CLI build watcher
and trigger redundant, racing test reruns on file changes.
Enforce `post` ordering on `angular:vitest-configuration` and reset
`config.server.watch = null` in a post `configResolved` hook so Vite
uses its no-op watcher.
There was a problem hiding this comment.
Code Review
This pull request moves the logic for disabling the Vite server file watcher from the executor configuration to a post-enforced configResolved hook in the Vitest configuration plugin, ensuring Vitest's internal hooks do not reset server.watch. A test case was also added to verify this behavior. However, a critical issue was identified in the configResolved hook implementation: Vite does not support the object form (with order and handler) for configResolved, which would cause a runtime TypeError. It is recommended to change it to a standard function hook.
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In Vitest 5, the internal
vitest:config:appendplugin uses a postconfigResolvedhook that resetsserver.watchto{}when watch mode is enabled (server.watch ??= {}), overriding theserver: { watch: null }setting passed invitestServerConfig. This caused Vite to start a duplicate Chokidar file watcher alongside the Angular CLI build watcher and trigger redundant, racing test reruns on file changes.Enforce
postordering onangular:vitest-configurationand resetconfig.server.watch = nullin a postconfigResolvedhook so Vite uses its no-op watcher.