Similar concerns.
We have the same Reason code running both on server and browser. In the server it runs on Node, but we want to move to native OCaml (with Jane Street’s Base) in the future.
This is a weird place to be in - our codebase started before Belt, and we used stdlib collection modules (Set, Map etc.) extensively. As per Belt’s documentation, they don’t map nicely to Javascript since they use functors which creates large closures. We however occasionally use convenience functions from Belt (eg: Belt.List.hasAssoc
) when they are unavailable in stdlib. We try to keep this to a minimum so we can port to native in the future. I also for reasons of familiarity like |> over ->.
There seem to be three choices:
- Fully adopt Belt - is there a native version in the works?
- Move to js_of_ocaml and use Base on both browser and client. (we have code that relies on ReasonReact which might have to be rewritten)
- Create a Belt wrapper and do conditional compilation for server and client.