Subscribe on changes!

Rename @hmr module for TypeScript tooling compatibility

avatar
May 8th 2020

Is your feature request related to a problem? Please describe. TypeScript editor tools complain that they Cannot find module '@hmr'.:

VSCodium

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.

avatar
May 8th 2020

closed via eab49a4