HMR doesn't accept local paths
I'd expect hot.accept(deps)
to take local paths, preferably using the same node resolution algorithm (i.e. no file extension) as standard imports. Currently, you have to pass the absolute URL including extension:
// src/App.tsx
import Counter from './Counter'
import { hot } from 'vite/hmr'
if (__DEV__) {
console.log(hot)
- hot.accept('./Counter', module => {
+ hot.accept('/src/Counter.tsx', module => {
console.log(module)
})
}
I'd expect hot.accept('./Counter')
to do the same as hot.accept('./Counter.tsx')
or at least print an error in the (browser or vite
) console. Currently, it silently does nothing.
Debug logs:
vite:hmr /src/App.tsx imports /src/Counter.tsx +13ms
vite:hmr /src/App.tsx accepts C:/src/Counter