ocsigen / js_of_ocaml

Compiler from OCaml to Javascript.
http://ocsigen.org/js_of_ocaml/
Other
957 stars 187 forks source link

Compilation of OCaml inside the browser? #1092

Closed TyOverby closed 1 year ago

TyOverby commented 3 years ago

The examples for the jsoo_toplevel are very compelling! However, for an application that I'm developing, I'm not interested in a top-like interface, but rather that behaves more like a regular on-disk compilation:

However, some aspects of the toplevel experience are nice, like the guarantee that the code being run uses the same libraries as the code running it.

Is this style of interaction with jsoo possible/easy? Where would one look for the APIs to make such a program posible?

ejgallego commented 3 years ago

Last time I looked into this [some quite time ago] compiler-libs API was still hard to use to embed the compiler so you could produce a .cmo which can then be translated. [on the file .cmo to .js did work fine and we used this to load Coq's plugins in jsCoq]

I think @gasche mentioned that work was underway to improve the use of "ocamlc as a library", but I'm not sure what the current status is.

hhugo commented 3 years ago

@TyOverby, have you made any discovery ? Have you looked at https://github.com/ocaml-sf/learn-ocaml ?

TyOverby commented 3 years ago

I haven't tried in a very long time; @pmwhite did some experimentation a big ago though, did you use the toplevel, or did you find a way to get it to compile files like normal?

pmwhite commented 2 years ago

@TyOverby I was indeed using the toplevel, sadly. I believe I was doing this experimentation around the time this issue was originally created, so it seems likely that it was motivated by what I was doing.

hhugo commented 1 year ago

reopen if still needed

nickbetteridge commented 1 year ago

@hhugo I would be very interested in being able to use something like this - especially if it was along the lines of using something like irmin as a repository, compiling ocaml -> javascript, and finally being able to launch html in the browser using the repository. An added benefit is that the repo could be exported. irmin-indexeddb is available!