Rename @hmr module for TypeScript tooling compatibility
Is your feature request related to a problem? Please describe.
TypeScript editor tools complain that they Cannot find module '@hmr'.
:
Describe the solution you'd like
Move or alias @hmr
to vite/hmr
. Then, typings can be provided from the vite
package itself.
import { hot } from 'vite/hmr'
// TypeScript knows what `hot` is now!
Describe alternatives you've considered
Users can declare the @hmr
module themselves in a .d.ts
file:
declare module '@hmr' {
export const hot: {
// accept, dispose, on, etc.
}
}
This requires duplicating type information already available in client.ts and breaks projects if the hmr API changes.
Additional context
It may also be worth allowing __DEV__
to be imported from a module such as vite/env
. This would also free TypeScript users from having to declare a global boolean in a declaration file.