You need to tell js_of_ocaml the list of cmi that you want to export. [jsoo_listunits] can compute the list of cmi from a findlib library. Because fac is not installed, you'll need to be explicit. There might be some better wait to integrate with dune but the following should change should do what you want. (rule (targets export.txt) (deps eval.bc *fac/fac.cma*) (action (run jsoo_listunits -o %{targets} stdlib *fac/.fac.objs/byte/fac.cmi*))) H On Sun, May 26, 2019 at 2:27 PM Kenichi Asai wrote: > I want to create a web page where I can execute an OCaml expression > that mentions a prebuilt user-defined library. I find the following > example in the js_of_ocaml/toplevel repository: > > https://github.com/ocsigen/js_of_ocaml/tree/master/toplevel/examples/eval > > Can I extend this example so that the toplevel is compiled with a > user-defined library? The attached program contains the following > where the first three files are copied from the example in the > js_of_ocaml/toplevel repository. > > toplevel/ -- dune > -- eval.ml > -- index.html > -- fac/ -- dune > -- fac.ml > > I intend that fac.ml is compiled as a library and I want to use it in > the toplevel. I added "fac" in the libraries stanza of the toplevel > dune file (as in the attached file): > > (executables > (names eval) > (libraries > fac > js_of_ocaml-compiler > js_of_ocaml-toplevel) > (link_flags (:standard -linkall)) > (preprocess (pps js_of_ocaml-ppx))) > > Naturally, fac.ml is compiled and I can use it in the eval.ml, but it > is not visible from the toplevel. I included the following part in > the index.html (as in the attached file): > > >
> > but the output says: > > File "/dev/fake_stdin", line 2, characters 6-12: > Error: Unbound module Fac > > Thank you in advance. > > -- > Kenichi Asai >