How to compile plugins without access to main application source code

(This is a repost of my GH discussions post, but I get the feeling that this place is more active.)

I saw in the documentation this part about loading additional files at runtime, for example for creating plugins for a larger application.

The example is simple enough and demonstrates how this works when you have access to both the source code of the main application and the plugin implementation. For simplicity (I assume!), the plugin implementation in the example is added as a subdirectory.

However, what the guide does not explain is:

  • Can I put the source code of the plugin in another location? How do I tell dune where to look?
  • Can I build the plugin without access to the source code of the main application? I would assume all I need are the .mli files (or maybe .cm(x)a?), which can be published with compiled releases of the main application.
  • If this can be done, what does the “at runtime” part look like? Where will the main application look for plugins, what format should they be in?

I would appreciate any pointers, expansions to the guide, or even links to projects which utilise this feature this way.