@@ -597,6 +597,75 @@ fn compile_file(
597597 ) ;
598598 }
599599
600+ match & module. source_type {
601+ SourceType :: SourceFile ( SourceFile {
602+ interface : Some ( Interface { path, .. } ) ,
603+ ..
604+ } ) => {
605+ // we need to copy the source file to the build directory.
606+ // editor tools expects the source file in lib/bs for finding the current package
607+ // and in lib/ocaml when referencing modules in other packages
608+ let _ = std:: fs:: copy (
609+ std:: path:: Path :: new ( & package. path ) . join ( path) ,
610+ std:: path:: Path :: new ( & package. get_build_path ( ) ) . join ( path) ,
611+ )
612+ . expect ( "copying source file failed" ) ;
613+
614+ let _ = std:: fs:: copy (
615+ std:: path:: Path :: new ( & package. path ) . join ( path) ,
616+ std:: path:: Path :: new ( & package. get_ocaml_build_path ( ) )
617+ . join ( std:: path:: Path :: new ( path) . file_name ( ) . unwrap ( ) ) ,
618+ )
619+ . expect ( "copying source file failed" ) ;
620+ }
621+ _ => ( ) ,
622+ }
623+ match & module. source_type {
624+ SourceType :: SourceFile ( SourceFile {
625+ implementation : Implementation { path, .. } ,
626+ ..
627+ } ) => {
628+ // we need to copy the source file to the build directory.
629+ // editor tools expects the source file in lib/bs for finding the current package
630+ // and in lib/ocaml when referencing modules in other packages
631+ let _ = std:: fs:: copy (
632+ std:: path:: Path :: new ( & package. path ) . join ( path) ,
633+ std:: path:: Path :: new ( & package. get_build_path ( ) ) . join ( path) ,
634+ )
635+ . expect ( "copying source file failed" ) ;
636+
637+ let _ = std:: fs:: copy (
638+ std:: path:: Path :: new ( & package. path ) . join ( path) ,
639+ std:: path:: Path :: new ( & package. get_ocaml_build_path ( ) )
640+ . join ( std:: path:: Path :: new ( path) . file_name ( ) . unwrap ( ) ) ,
641+ )
642+ . expect ( "copying source file failed" ) ;
643+ }
644+ _ => ( ) ,
645+ }
646+
647+ // copy js file
648+ match & module. source_type {
649+ SourceType :: SourceFile ( SourceFile {
650+ implementation : Implementation { path, .. } ,
651+ ..
652+ } ) => {
653+ let source = helpers:: get_source_file_from_rescript_file (
654+ & std:: path:: Path :: new ( & package. path ) . join ( path) ,
655+ & root_package. config . get_suffix ( ) ,
656+ ) ;
657+ let destination = helpers:: get_source_file_from_rescript_file (
658+ & std:: path:: Path :: new ( & package. get_build_path ( ) ) . join ( path) ,
659+ & root_package. config . get_suffix ( ) ,
660+ ) ;
661+
662+ if source. exists ( ) {
663+ let _ = std:: fs:: copy ( & source, & destination) . expect ( "copying source file failed" ) ;
664+ }
665+ }
666+ _ => ( ) ,
667+ }
668+
600669 if helpers:: contains_ascii_characters ( & err) {
601670 if package. is_pinned_dep || package. is_local_dep {
602671 // supress warnings of external deps
0 commit comments