Repository navigation
Conversation
|
the failing CI check is in hmr-ssr.spec.ts (SSR accept-exports timeout) looks unrelated to this change since it doesn't touch that code path, seems like it might be a flaky test on the Windows runner. |
|
Isn't the path already normalized before calling vite/packages/vite/src/node/server/index.ts Lines 889 to 890 in 640202a Unless the issue is somewhere else invoking If we're looking purely from |
you're right, the path is already normalized upstream. I'll extend the fix to all file-accepting methods in EnvironmentModuleGraph (getModulesByFile, onFileChange, onFileDelete) so the API normalizes on behalf of callers, consistent with how createFileOnlyEntry already does it. |
8e84eae to
9749194
Compare
9749194 to
97de036
Compare
Ran into #22264 while investigating HMR silently doing nothing on Windows. The root cause is that on Windows, chokidar emits paths with backslashes (
C:\project\src\foo.ts), butfileToModulesMapkeys are stored with forward slashes. WhenonFileChangecallsgetModulesByFile(file)without normalizing first, the Map lookup misses every time and no modules get invalidated.The fix is one line,
file = normalizePath(file)at the top ofEnvironmentModuleGraph.onFileChange.normalizePathwas already imported in the file (it's used a few lines down increateFileOnlyEntry), so nothing else needed to change. The server-level watcher handler inindex.tsalready normalizes before calling into the module graph, butonFileChangeis a public method and other callers like plugins can reach it directly with raw paths, so the normalization belongs here defensively.Added two tests: a cross-platform one that passes a double-slash path (
/project//src/foo.ts) to provepath.posix.normalizeis being applied before the lookup, and a Windows-specific one using an actual backslash path that uses{ skip: !isWindows }(same pattern assourcemap.spec.ts) so it's skipped on macOS/Linux CI but will run on Windows runners.