Currently, fast refresh is working for a file only if either
- the file extension ends with an "x" (e.g. "jsx", "tsx") or
- the code in the file imports
React
in some way
Now when using a compile-to-JS language like ReScript with the new JSX runtime enabled, one will get .js
or .mjs
files with imports from "react/jsx-runtime" or "react/jsx-dev-runtime", but no React
import, and fast refresh will not work for these files.
- Install dependencies and start vite:
npm i
npm run dev
- Increment counter
- Change the text in
TestComponent.bs.js
(alternatively change it in TestComponent.res and runnpm run res:build
to recompile). Observe that the counter value is reset to 0.
- Run
npx patch-package
to apply the patch frompatches/@vitejs+plugin-react+3.0.1.patch
. - Restart vite and repeat the above test steps.
- Observe that TestComponent now refreshs correctly and the counter value remains unchanged.