These files are generated using individual dune
executable stanzas, so each file is produced independently. These executables have some common dependencies in
I heard something about separate compilation for js_of_ocaml, but not sure if this is relevant. The only solution I see is to extract common dependencies and jsoo runtime into a single file (or some separate files) and include it to the web page, but I have no idea whether this is possible at all.
Can anyone give an advice on how to handle this?
Here is my
dune file for one of the generated js files:
(executable (name scaffold) (libraries components) (preprocess (pps js_of_ocaml-ppx)))
components is my GUI library for client-side usage, which has the next
(library (name components) (libraries js_of_ocaml js_of_ocaml-lwt js_of_ocaml-tyxml components_tyxml) (preprocess (pps js_of_ocaml-ppx)))
components_tyxml is my GUI library for server/client side usage, with the following
(library (name components_tyxml) (libraries str tyxml color))
scaffold.bc.js has 8.5MB in dev mode and 332KB in release mode. It is very simple, so not so large as other js files I’ve described above.
The problem is that
components library is a dependency for every other js executable, so it is actually loaded as many times as the number of js files.