I want to use JSOO to build a JS package that contains core logic that will run in a browser, presenting a JSON-y API to be consumed by JS front-end code. This seems like a good way to use js_of_ocaml: all the complicated JS UI stuff doesn’t need to be replicated in OCaml, but you can still keep your core domain logic there.
I’ve got dune building my .js using JSOO and exposing functions to JS. If I copy that JS by hand to my front-end project, it works. Now I want to be able to:
- Expose the output as something that my front-end project can bundle without a manual copying step
- Be able to make changes to in a dev environment and see the changes quickly in a browser
To do this with ReScript compiling my core
.ml syntax project, I have
esbuild running under a watcher +
rescript build -w. I run
rescript build -w on my front-end, with the core project
npm linked in. Any change I make to either project (core or front-end) shows up effectively immediately in the browser.
Has anybody got advice on how to get a similar setup working with JSOO compiling the core project in place of ReScript, and JS on the front end? Ideally on github, but otherwise hints appreciated!