File tree Expand file tree Collapse file tree 4 files changed +18
-12
lines changed Expand file tree Collapse file tree 4 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ pub fn clean_mjs_files(build_state: &BuildState) {
8383 . join ( & source_file. implementation . path )
8484 . to_string_lossy ( )
8585 . to_string ( ) ,
86- spec . get_suffix ( ) ,
86+ root_package . config . get_suffix ( spec ) ,
8787 ) )
8888 } else {
8989 None
Original file line number Diff line number Diff line change @@ -465,7 +465,7 @@ pub fn compiler_args(
465465 . unwrap( )
466466 )
467467 } ,
468- spec . get_suffix( )
468+ root_config . get_suffix( spec ) ,
469469 ) ,
470470 ] ;
471471 } )
@@ -734,11 +734,11 @@ fn compile_file(
734734 } ) => {
735735 let source = helpers:: get_source_file_from_rescript_file (
736736 & std:: path:: Path :: new ( & package. path ) . join ( path) ,
737- & spec . get_suffix ( ) ,
737+ & root_package . config . get_suffix ( spec ) ,
738738 ) ;
739739 let destination = helpers:: get_source_file_from_rescript_file (
740740 & std:: path:: Path :: new ( & package. get_build_path ( ) ) . join ( path) ,
741- & spec . get_suffix ( ) ,
741+ & root_package . config . get_suffix ( spec ) ,
742742 ) ;
743743
744744 if source. exists ( ) {
Original file line number Diff line number Diff line change @@ -105,10 +105,7 @@ pub fn read(build_state: &mut BuildState) -> CompileAssetsState {
105105 is_root : * package_is_root,
106106 suffix : root_package
107107 . config
108- . get_package_specs ( )
109- . first ( )
110- . map ( |spec| spec. get_suffix ( ) )
111- . unwrap ( ) ,
108+ . get_suffix ( root_package. config . get_package_specs ( ) . first ( ) . unwrap ( ) ) ,
112109 } ,
113110 ) ;
114111 let _ = ast_rescript_file_locations. insert ( res_file_path) ;
Original file line number Diff line number Diff line change @@ -127,8 +127,8 @@ impl PackageSpec {
127127 }
128128 }
129129
130- pub fn get_suffix ( & self ) -> String {
131- self . suffix . to_owned ( ) . unwrap_or ( ".js" . to_string ( ) )
130+ pub fn get_suffix ( & self ) -> Option < String > {
131+ self . suffix . to_owned ( )
132132 }
133133}
134134
@@ -456,6 +456,12 @@ impl Config {
456456 Some ( OneOrMore :: Multiple ( vec) ) => vec,
457457 }
458458 }
459+
460+ pub fn get_suffix ( & self , spec : & PackageSpec ) -> String {
461+ spec. get_suffix ( )
462+ . or ( self . suffix . clone ( ) )
463+ . unwrap_or ( ".js" . to_string ( ) )
464+ }
459465}
460466
461467#[ cfg( test) ]
@@ -476,8 +482,11 @@ mod tests {
476482 "# ;
477483
478484 let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
479- assert_eq ! ( config. get_suffix( ) , ".mjs" ) ;
480- assert_eq ! ( config. get_module( ) , "es6" ) ;
485+ let specs = config. get_package_specs ( ) ;
486+ assert_eq ! ( specs. len( ) , 1 ) ;
487+ let spec = specs. first ( ) . unwrap ( ) ;
488+ assert_eq ! ( spec. module, "es6" ) ;
489+ assert_eq ! ( config. get_suffix( spec) , ".mjs" ) ;
481490 }
482491
483492 #[ test]
You can’t perform that action at this time.
0 commit comments