-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
recommended workflow for hmr/fast refresh #131
Comments
I don't think this is needed, by default live-reload should work. It's not as fancy as hot reload, but probably more reliable. If you run |
I just tried adding |
I'm seeing this on my own example repo, where I've based the webpack and dune setup off of this one, only modifying the webpack file in a few places, e.g. setting |
I see similar errors when running the example:
|
This is not an error, it's just hot reloader saying it has to do full reload because it doesn't know how to inject new state (the reliability issues I mentioned above). Does the page actually show if you go to localhost:8000? Another thing I don't understand is how is |
After more thinking, I am not sure it makes sense to support HMR with jsoo-react in any case, as jsoo generates one single JS file with everything in it, while HMR expects multiple JS files across the app. There is no difference between hot module reloading and live reload when there is only 1 large JS module in the app. One day, there might be a way to generate individual js files from OCaml modules with jsoo, but until then, I think live reloading (which the As there is nothing actionable from the jsoo-react library perspective, I will close the issue, but feel free to reopen if I misunderstood, or there are any related issues when setting up a project. |
That makes sense. I did find this issue, which has a related pr that might eventually lead to the ability to compile to separate modules: ocsigen/js_of_ocaml#1161 |
I think I narrowed the above webpack error to this line, where the previous file is deleted before moving the new temp file into place: https://github.com/ocsigen/js_of_ocaml/blob/ae78b6ccebbeabb26232e22f8b2361e79b8c5542/compiler/lib/stdlib.ml#L729-L730 |
Hey @joprice. Totally, while running dune build (and I think other forms as well) it will nuke the files and re-generate them. This goes against the principle of hot module replacement, where only one module is re-generated and other modules that your bundle are loaded into the page can exchange old implementations with new ones and keep working as they were never changed. I'm not sure if there's anything we could to do enable it in the current form of jsoo. PS. The link that you shared points to the Jsoo stdlib module where they wrap a few functions to use while building/linking and other duties of the compiler. |
Is there a setup that allows for hmr or fast refresh? I enabled 'hot' in my webpack config, but I've run into a few issues: When I change a file in vim (running coc.nvim with ocaml-lsp), the js file is not generated. Explicitly running
dune build
gets it to generate, but then I see the error below:The text was updated successfully, but these errors were encountered: