@@ -576,38 +576,53 @@ let setup_js_rules_libraries =
576
576
| None -> Memo. return ()
577
577
| Some vlib ->
578
578
let * vlib = Resolve.Memo. read_memo vlib in
579
- let * includes =
580
- let + requires_link =
581
- let + requires_link =
582
- Lib.Compile. for_lib
583
- ~allow_overlaps: mel.allow_overlapping_dependencies
584
- (Scope. libs scope)
585
- vlib
586
- |> Lib.Compile. requires_link
587
- |> Memo.Lazy. force
588
- in
589
- let open Resolve.O in
590
- let + requires_link = requires_link in
591
- (* Whenever a `concrete_lib` implementation contains a field
592
- `(implements virt_lib)`, we also set up the JS targets for the
593
- modules defined in `virt_lib`.
579
+ let vlib_output = output_of_lib ~target_dir vlib in
580
+ (match vlib_output, output with
581
+ | `Public_library _ , `Private_library_or_emit _ ->
582
+ let info = Lib. info lib in
583
+ User_error. raise
584
+ ~loc: (Lib_info. loc info)
585
+ [ Pp. text
586
+ " Dune doesn't currently support building private implementations of \
587
+ virtual public libaries for `(modes melange)`"
588
+ ]
589
+ ~hints:
590
+ [ Pp. textf
591
+ " Add a `public_name` to the library `%s'."
592
+ (Lib_name. to_string (Lib_info. name info))
593
+ ]
594
+ | `Public_library _ , `Public_library _ | `Private_library_or_emit _ , _ ->
595
+ let * includes =
596
+ let + requires_link =
597
+ let + requires_link =
598
+ Lib.Compile. for_lib
599
+ ~allow_overlaps: mel.allow_overlapping_dependencies
600
+ (Scope. libs scope)
601
+ vlib
602
+ |> Lib.Compile. requires_link
603
+ |> Memo.Lazy. force
604
+ in
605
+ let open Resolve.O in
606
+ let + requires_link = requires_link in
607
+ (* Whenever a `concrete_lib` implementation contains a field
608
+ `(implements virt_lib)`, we also set up the JS targets for the
609
+ modules defined in `virt_lib`.
594
610
595
- In the cases where `virt_lib` (concrete) modules depend on any
596
- virtual modules (i.e. programming against the interface), we
597
- need to make sure that the JS rules that dune emits for
598
- `virt_lib` depend on `concrete_lib`, such that Melange can find
599
- the correct `.cmj` file, which is needed to emit the correct
600
- path in `import` / `require`. *)
601
- lib :: requires_link
602
- in
603
- cmj_includes ~requires_link ~scope lib_config
604
- in
605
- let output = output_of_lib ~target_dir vlib in
606
- parallel_build_source_modules
607
- ~sctx
608
- ~scope
609
- vlib
610
- ~f: (build_js ~dir ~output ~includes ~compile_flags )
611
+ In the cases where `virt_lib` (concrete) modules depend on any
612
+ virtual modules (i.e. programming against the interface), we
613
+ need to make sure that the JS rules that dune emits for
614
+ `virt_lib` depend on `concrete_lib`, such that Melange can find
615
+ the correct `.cmj` file, which is needed to emit the correct
616
+ path in `import` / `require`. *)
617
+ lib :: requires_link
618
+ in
619
+ cmj_includes ~requires_link ~scope lib_config
620
+ in
621
+ parallel_build_source_modules
622
+ ~sctx
623
+ ~scope
624
+ vlib
625
+ ~f: (build_js ~dir ~output: vlib_output ~includes ~compile_flags ))
611
626
and + () =
612
627
parallel_build_source_modules
613
628
~sctx
0 commit comments