Dune + rewriting of typed tree + dependencies: how to do better?

I have the following setup

  • a rewriter that does typechecking under the hood
  • a module A in a library
  • a module B in a library, which is preprocessed by rewriter above and which depends on A

I want to make dune to compile it. Current solution uses hardcoded -I .A.objs/byte switch for my rewriter. Can I do better?

What I’m ready to sacrifice (if it will be really required): having two modules in separate libraries.

Any ideas?