@@ -67,6 +67,14 @@ pub fn get_build_path(canonical_path: &str) -> String {
67
67
format ! ( "{}/lib/bs" , canonical_path)
68
68
}
69
69
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
+
70
78
pub fn get_ocaml_build_path ( canonical_path : & str ) -> String {
71
79
format ! ( "{}/lib/ocaml" , canonical_path)
72
80
}
@@ -80,6 +88,14 @@ impl Package {
80
88
get_build_path ( & self . path )
81
89
}
82
90
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
+
83
99
pub fn get_mlmap_path ( & self ) -> String {
84
100
self . get_build_path ( )
85
101
+ "/"
@@ -494,17 +510,19 @@ pub fn get_source_files(
494
510
} ;
495
511
496
512
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) {
499
516
Ok ( files) => map. extend ( files) ,
517
+
500
518
Err ( _e) => log:: error!(
501
519
"Could not read folder: {:?}. Specified in dependency: {}, located {:?}..." ,
502
520
path_dir. to_path_buf( ) . into_os_string( ) ,
503
521
package_name,
504
522
package_dir
505
523
) ,
506
- }
507
- }
524
+ } ,
525
+ } ;
508
526
509
527
map
510
528
}
@@ -594,8 +612,48 @@ pub fn parse_packages(build_state: &mut BuildState) {
594
612
}
595
613
let build_path_abs = package. get_build_path ( ) ;
596
614
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
+ } ) ;
599
657
600
658
package. namespace . to_suffix ( ) . iter ( ) . for_each ( |namespace| {
601
659
// generate the mlmap "AST" file for modules that have a namespace configured
0 commit comments