ocaml-vdom not working with wasm_of_ocaml
I recently tried to run the examples in this repo with the newly released wasm_of_ocaml (https://discuss.ocaml.org/t/ann-js-of-ocaml-6-0-1-wasm-of-ocaml/16160). I tried the counters app. It builds okay. However, running in the browser doesn't render much. Jsoo samples manipulating dom works out of the box, so I presumed vdom would work well with wasm_of_ocaml. Is there some quick setting I can use perhaps to make this work?
Hello, thanks for the report. I tried to build ocaml-vdom with wasm_of_ocaml but the wasm_of_ocaml OPAM package fails to build on my old machine (the binaryen-bin package runs out of memory I think), so it will take me some time to investigate. If you have more precise description of the issue you are facing, that could be useful in the meantime. Thanks.
See https://github.com/ocsigen/js_of_ocaml/issues/1948
Thanks for the pointer @vouillon! I understand that onload may trigger before the script is evaluated so one should use the following shim instead of a direct call to Window.set_onload in order to be WASM-compatible (with an obvious definition for Js_browser.Document.ready_state):
let set_onload f =
let open Js_browser in
if Document.ready_state document = "complete" then f ()
else Window.set_onload f
@bikallem would you like to give it a try and report back if it works? Thanks!