summarizing findings:
-
js_of_ocaml
deals with just that - generating js of ocaml; javascript imports and interop is possible through creating bindings to js code - you can still pass the output of jsoo to the standard javascript build pipelines (including webpack), for example: Create bindings for JS library · Issue #718 · ocsigen/js_of_ocaml · GitHub
- I couldn’t find any more complete and more complex examples like using css modules or internationalization, that require “coordination” between both the css files and the js output (I’ll assume there’s nothing existing)
if you want reactive apps:
- the only reactjs bindings I found were GitHub - fxfactorial/ocaml-reactjs: Write OCaml, use ReactJS. : DEPRECATED: USE REASONREACT , but these are 5 years old, so they are using class components (no hooks and effects)
- there’s GitHub - jchavarri/jsoo-react: js_of_ocaml bindings for ReactJS. Based on ReasonReact. which is at “experimental stage”, I couldn’t test since it didn’t build for me (ocaml syntax for it is kind of verbose compared to jsx)
(the above was disappointing since in my experience building a vdom reactive library takes a lot more effort and energy than people realize. It is not enough to build html diffing logic - there’s all kinds of weird browsers, with quirks, accessibility, touch devices, event handling differences that need to be standardized. These are not fun problems to solve and are ones that reactjs has solved, but less widely used libraries have not)
- there’s GitHub - LexiFi/ocaml-vdom: Elm architecture and (V)DOM for OCaml which uses Elm-like architecture
-
GitHub - janestreet/bonsai: A library for building dynamic webapps, using Js_of_ocaml which I couldn’t test since the released version does not have examples and the
master
version didn’t build for me can't get started · Issue #12 · janestreet/bonsai · GitHub ; there were alsoasync
dependencies, so I’m not sure ifasync
is a necessity, or you can still uselwt
, with the only caveat that you would need to pay the size for both libraries)
at first glance, as someone without too much ocaml experience - building a modern reactive browser application with the existing jsoo ecosystem is not that straightforward. especially compared to bucklescript, which was a smoother experience to integrate (at least in terms of tutorials, examples and etc. - these seem to be lacking in jsoo land, so simple things take a good chunk of time to experiment), but also one that is no longer available