@@ -67,6 +67,14 @@ pub fn get_build_path(canonical_path: &str) -> String {
6767 format ! ( "{}/lib/bs" , canonical_path)
6868}
6969
70+ pub fn get_js_path ( canonical_path : & str ) -> String {
71+ format ! ( "{}/lib/js" , canonical_path)
72+ }
73+
74+ pub fn get_es6_path ( canonical_path : & str ) -> String {
75+ format ! ( "{}/lib/es6" , canonical_path)
76+ }
77+
7078pub fn get_ocaml_build_path ( canonical_path : & str ) -> String {
7179 format ! ( "{}/lib/ocaml" , canonical_path)
7280}
@@ -80,6 +88,14 @@ impl Package {
8088 get_build_path ( & self . path )
8189 }
8290
91+ pub fn get_js_path ( & self ) -> String {
92+ get_js_path ( & self . path )
93+ }
94+
95+ pub fn get_es6_path ( & self ) -> String {
96+ get_es6_path ( & self . path )
97+ }
98+
8399 pub fn get_mlmap_path ( & self ) -> String {
84100 self . get_build_path ( )
85101 + "/"
@@ -494,17 +510,19 @@ pub fn get_source_files(
494510 } ;
495511
496512 let path_dir = Path :: new ( & source. dir ) ;
497- if ( build_dev_deps && type_ == & Some ( "dev" . to_string ( ) ) ) || type_ != & Some ( "dev" . to_string ( ) ) {
498- match read_folders ( filter, package_dir, path_dir, recurse) {
513+ match ( build_dev_deps, type_) {
514+ ( false , Some ( type_) ) if type_ == "dev" => ( ) ,
515+ _ => match read_folders ( filter, package_dir, path_dir, recurse) {
499516 Ok ( files) => map. extend ( files) ,
517+
500518 Err ( _e) => log:: error!(
501519 "Could not read folder: {:?}. Specified in dependency: {}, located {:?}..." ,
502520 path_dir. to_path_buf( ) . into_os_string( ) ,
503521 package_name,
504522 package_dir
505523 ) ,
506- }
507- }
524+ } ,
525+ } ;
508526
509527 map
510528}
@@ -594,8 +612,48 @@ pub fn parse_packages(build_state: &mut BuildState) {
594612 }
595613 let build_path_abs = package. get_build_path ( ) ;
596614 let bs_build_path = package. get_ocaml_build_path ( ) ;
597- helpers:: create_build_path ( & build_path_abs) ;
598- helpers:: create_build_path ( & bs_build_path) ;
615+ helpers:: create_path ( & build_path_abs) ;
616+ helpers:: create_path ( & bs_build_path) ;
617+ let root_config = build_state
618+ . get_package ( & build_state. root_config_name )
619+ . expect ( "cannot find root config" ) ;
620+
621+ root_config. config . get_package_specs ( ) . iter ( ) . for_each ( |spec| {
622+ if !spec. in_source {
623+ // we don't want to calculate this if we don't have out of source specs
624+ // we do this twice, but we almost never have multiple package specs
625+ // so this optimization is less important
626+ let relative_dirs: AHashSet < PathBuf > = match & package. source_files {
627+ Some ( source_files) => source_files
628+ . keys ( )
629+ . map ( |source_file| {
630+ Path :: new ( source_file)
631+ . parent ( )
632+ . expect ( "parent dir not found" )
633+ . to_owned ( )
634+ } )
635+ . collect ( ) ,
636+ _ => AHashSet :: new ( ) ,
637+ } ;
638+ if spec. is_common_js ( ) {
639+ helpers:: create_path ( & package. get_js_path ( ) ) ;
640+ relative_dirs. iter ( ) . for_each ( |path_buf| {
641+ helpers:: create_path_for_path ( & Path :: join (
642+ & PathBuf :: from ( package. get_js_path ( ) ) ,
643+ path_buf,
644+ ) )
645+ } )
646+ } else {
647+ helpers:: create_path ( & package. get_es6_path ( ) ) ;
648+ relative_dirs. iter ( ) . for_each ( |path_buf| {
649+ helpers:: create_path_for_path ( & Path :: join (
650+ & PathBuf :: from ( package. get_es6_path ( ) ) ,
651+ path_buf,
652+ ) )
653+ } )
654+ }
655+ }
656+ } ) ;
599657
600658 package. namespace . to_suffix ( ) . iter ( ) . for_each ( |namespace| {
601659 // generate the mlmap "AST" file for modules that have a namespace configured
0 commit comments