Skip to content

Improve HMR with Vite #727

@mattrunyon

Description

@mattrunyon

Switching from CRA to Vite also moves us off of Webpack. Webpack possibly does some heuristics to make HMR function in different cases where Vite does not HMR properly.

Vite does not HMR if there are items it cannot determine are side-effect free. Some items like shortcuts possibly break this with the current singleton implementation and should use a class instead.

Also, HOC may break fast refresh. I am not sure if our current redux setup breaks this since it uses HOC.

Any imports such as import 'myScript.js' or import 'myStyle.css' will also be considered as side-effects most likely since the only reason an import like that exists is to execute something in the file. Not sure if sass triggers this w/ Vite, but it wouldn't surprise me

Our log package could be an issue b/c in all the components we usually have a setup log line in the top level of the file which might be marked as a side-effect

vitejs/vite#4577 (comment)
vitejs/vite-plugin-react#21

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions