So I did some digging to transform the JavaScript code to remove the export.
It is possible to transform the code, remove the export of the JavaScript side.
However, the approach didn’t work for the following scenario:
Main.res
switch ReactDOM.querySelector("#root") {
| None => Console.log("Root element not found")
| Some(rootElement) => {
let root = ReactDOM.Client.createRoot(rootElement)
ReactDOM.Client.Root.render(
root,
<React.StrictMode>
<Settings />
</React.StrictMode>,
)
}
}
Settings.res
@react.component
let make = () => {
<div className="bg-primary-500 h-100">
{React.string("Settings y")}
</div>
}
Changing Settings.res did result in a change in Main.res.mjs.
The file timestamp is different and Vite picks this up.
When there is a signature file for Settings.res, this does not happen.
Ergo, signature files are necessary for fast refresh to work.
(You could easily test this when with bun create rescript-app@next, removing App.resi will no longer allow hmr to work)