CRA's HMR is a mess that breaks more often than it works, but I haven't had any problems with Vite's HMR after using it for the past three (I think?) years.
Because you did not use Vite.
I can’t speak for how it works in other frameworks but HMR for React works flawlessly in Vite.