Subscribe on changes!

HMR doesn't accept local paths

avatar
May 8th 2020

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.

avatar
May 8th 2020

Debug logs:

  vite:hmr         /src/App.tsx imports /src/Counter.tsx +13ms
  vite:hmr         /src/App.tsx accepts C:/src/Counter
avatar
May 8th 2020

Hmm... another windows bug :/

Please don't ignore the template when reporting bugs.