Using dune for umbrella libraries in mdx

I’m trying to use dune to build a collection of small libraries and an umbrella library that re-exports them. So I have this dune-project:

(lang dune 3.18)
(name dune-umbrella-repro)
(version dev)
(generate_opam_files)
(using mdx 0.4)
 
(source (github xvw/dune-umbrella-repro))
(license MIT)

(authors "Xavier Van de Woestyne <xaviervdw@gmail.com>")
(maintainers "Xavier Van de Woestyne <xaviervdw@gmail.com>")

(package
 (name subject-of-umbrella)
 (synopsis "Subject of umbrella")
 (description "Subject of umbrella")
 (depends
  (ocaml (>= 5.3.0))))

(package
 (name dune-umbrella-repro)
 (synopsis "umbrella")
 (description "Umbrella library")
 (depends
  (ocaml (>= 5.3.0))
  (subject-of-umbrella :version)
  (mdx :with-test)
  (ocamlformat :with-dev-setup)
  (ocp-indent :with-dev-setup)
  (ocaml-lsp-server :with-dev-setup)
  (utop :with-dev-setup)))

My idea would be to describe Subject as a dependency of Umbrella and allow re-exporting of Subject so that depending on Umbrella automatically makes Subject accessible. So I have Subject :

(library
 (name subject)
 (public_name subject-of-umbrella))

With one A.ml :

let x = 10
let y = "foo"

And my umbrella lib:

(library
 (name umbrella)
 (public_name dune-umbrella-repro)
 (modules_without_implementation umbrella)
 (libraries (re_export subject-of-umbrella)))

with only umbrella.mli

module Subject = Subject

everything compiles perfectly. So I add a ROOT/doc/dune and ROOT/doc/test.mld

(documentation
 (package dune-umbrella-repro))

(mdx
 (files *.mld)
 (libraries dune-umbrella-repro))

and

{0 Hello}

{eof@ocaml[
# let x = Umbrella.Subject.A.x ;;
]eof}

If I try to dune test, I face to the following error:

# dune test
File "doc/test.mld", line 1, characters 0-0:
diff --git a/_build/default/doc/test.mld b/_build/default/doc/.mdx/test.mld.corrected
index a55363c..6308712 100644
--- a/_build/default/doc/test.mld
+++ b/_build/default/doc/.mdx/test.mld.corrected
@@ -2,4 +2,6 @@

 {eof@ocaml[
 # let x = Umbrella.Subject.A.x ;;
+Line 1, characters 9-29:
+Error: The module Umbrella.Subject is an alias for module Subject, which is missing
 ]eof}
\ No newline at end of file

So I guess I must be missing something? Because if I add my dependency to subject:

(documentation
 (package dune-umbrella-repro))

(mdx
  (files *.mld)
-  (libraries dune-umbrella-repro))
+  (libraries subject-of-umbrella dune-umbrella-repro))

Everything works perfectly! So I have several questions:

  • Is what I want to do possible?
  • Is it possible that this is only a problem in the context of testing?

Edit:

Yes, if I have foo.ml

let x = Subject.A.x ;;
let () = print_int x;;

With this package description:

(package
 (name foo)
 (synopsis "Subject of umbrella")
 (description "Subject of umbrella")
 (depends
  (ocaml (>= 5.3.0))
  (dune-umbrella-repro :version)))

and the following dune file

(executable
 (name foo)
 (public_name foo)
 (package foo)
 (libraries dune-umbrella-repro))

Everything works fine so I guess it is related to mdx ?