Skip to content

Conversation

@abbasyed
Copy link
Contributor

@abbasyed abbasyed commented Oct 26, 2025

Description

Fixes path comparison issue in ensureWatchedFile where Windows paths were not normalized before comparison with POSIX-formatted root path, causing unnecessary files to be added to the watcher.
fixes #20956

Changes

  • Normalized file path using normalizePath() before startsWith() comparison in ensureWatchedFile function
  • Added comment explaining cross-platform path handling
  • Added comprehensive test coverage (6 test cases)

Testing

  • All 108 tests pass (including 6 new tests for ensureWatchedFile)
  • Tests verify Windows path normalization, POSIX compatibility, and edge cases
  • TypeScript type checks pass with 0 errors
  • ESLint and Prettier checks pass

Additional Notes

  • No new imports required (normalizePath already exists in same file)
  • No performance regression (lightweight string operations)
  • Cross-platform compatible (tested for both Windows and POSIX paths)

…patibility

Fixes path comparison issue where Windows paths with backslashes were not
properly compared against POSIX-formatted root paths, causing unnecessary
files to be added to the watcher.

The root path is always normalized to POSIX format in Vite's config, but
file paths passed to ensureWatchedFile may come in Windows format. This
change normalizes the file path before comparison to ensure consistent
behavior across platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ensureWatchedFile false positive on windows

1 participant