Direct compilation of a bytecode program to JavaScript. This mode allows js_of_ocaml to perform whole program deadcode elimination and whole program inlining.
Separate compilation, where compilation units are compiled to JavaScript separately and then linked together. This mode is useful during development as it builds more quickly.
The separate compilation mode will be selected when the build profile is dev , which is the default. There is currently no other way to control this behaviour.
By default dune builds he projects in dev mode, meaning including a series of flags to speed up compilation and have good debug information. If you want a stripped out binary, you need to build in release mode. If I am not mistaken this is just dune build --profile=release.
You can use the dune-workspace file if you want to preselect a different profile by default (not sure if this is a new dune 2 feature or was there, I never used it): https://dune.readthedocs.io/en/stable/dune-files.html
Thanks for the explanations, I had never used dune profiles before.
yes it works!
writing a dune-workspace also works (with dune 1.11)
Contrary to what the cited doc seems to suggest, here compiling with the “release” profile is much faster. But that’s probably because the program here is too trivial.