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 @@ -488,7 +488,7 @@ pub fn compiler_args(
488488 . unwrap( )
489489 )
490490 } ,
491- spec . get_suffix( )
491+ root_config . get_suffix( spec ) ,
492492 ) ,
493493 ] ;
494494 } )
@@ -680,11 +680,11 @@ fn compile_file(
680680 } ) => {
681681 let source = helpers:: get_source_file_from_rescript_file (
682682 & std:: path:: Path :: new ( & package. path ) . join ( path) ,
683- & spec . get_suffix ( ) ,
683+ & root_package . config . get_suffix ( spec ) ,
684684 ) ;
685685 let destination = helpers:: get_source_file_from_rescript_file (
686686 & std:: path:: Path :: new ( & package. get_build_path ( ) ) . join ( path) ,
687- & spec . get_suffix ( ) ,
687+ & root_package . config . get_suffix ( spec ) ,
688688 ) ;
689689
690690 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
@@ -435,6 +435,12 @@ impl Config {
435435 Some ( OneOrMore :: Multiple ( vec) ) => vec,
436436 }
437437 }
438+
439+ pub fn get_suffix ( & self , spec : & PackageSpec ) -> String {
440+ spec. get_suffix ( )
441+ . or ( self . suffix . clone ( ) )
442+ . unwrap_or ( ".js" . to_string ( ) )
443+ }
438444}
439445
440446#[ cfg( test) ]
@@ -455,8 +461,11 @@ mod tests {
455461 "# ;
456462
457463 let config = serde_json:: from_str :: < Config > ( json) . unwrap ( ) ;
458- assert_eq ! ( config. get_suffix( ) , ".mjs" ) ;
459- assert_eq ! ( config. get_module( ) , "es6" ) ;
464+ let specs = config. get_package_specs ( ) ;
465+ assert_eq ! ( specs. len( ) , 1 ) ;
466+ let spec = specs. first ( ) . unwrap ( ) ;
467+ assert_eq ! ( spec. module, "es6" ) ;
468+ assert_eq ! ( config. get_suffix( spec) , ".mjs" ) ;
460469 }
461470
462471 #[ test]
You can’t perform that action at this time.
0 commit comments