@@ -224,6 +224,8 @@ pub enum DeprecationWarning {
224224 BsDependencies ,
225225 BsDevDependencies ,
226226 BscFlags ,
227+ PackageSpecsEs6 ,
228+ PackageSpecsEs6Global ,
227229}
228230
229231#[ derive( Debug , Clone , Eq , PartialEq , Hash ) ]
@@ -746,6 +748,23 @@ impl Config {
746748 self . deprecation_warnings . push ( DeprecationWarning :: BscFlags ) ;
747749 }
748750
751+ let ( has_es6, has_es6_global) = match & self . package_specs {
752+ None => ( false , false ) ,
753+ Some ( OneOrMore :: Single ( spec) ) => ( spec. module == "es6" , spec. module == "es6-global" ) ,
754+ Some ( OneOrMore :: Multiple ( specs) ) => (
755+ specs. iter ( ) . any ( |spec| spec. module == "es6" ) ,
756+ specs. iter ( ) . any ( |spec| spec. module == "es6-global" ) ,
757+ ) ,
758+ } ;
759+ if has_es6 {
760+ self . deprecation_warnings
761+ . push ( DeprecationWarning :: PackageSpecsEs6 ) ;
762+ }
763+ if has_es6_global {
764+ self . deprecation_warnings
765+ . push ( DeprecationWarning :: PackageSpecsEs6Global ) ;
766+ }
767+
749768 Ok ( ( ) )
750769 }
751770}
@@ -1081,6 +1100,55 @@ pub mod tests {
10811100 assert ! ( config. get_deprecations( ) . is_empty( ) ) ;
10821101 }
10831102
1103+ #[ test]
1104+ fn test_package_specs_es6_global_deprecation ( ) {
1105+ let json = r#"
1106+ {
1107+ "name": "testrepo",
1108+ "sources": {
1109+ "dir": "src",
1110+ "subdirs": true
1111+ },
1112+ "package-specs": [
1113+ {
1114+ "module": "es6-global",
1115+ "in-source": true
1116+ }
1117+ ],
1118+ "suffix": ".mjs"
1119+ }
1120+ "# ;
1121+
1122+ let config = Config :: new_from_json_string ( json) . expect ( "a valid json string" ) ;
1123+ assert_eq ! (
1124+ config. get_deprecations( ) ,
1125+ [ DeprecationWarning :: PackageSpecsEs6Global ]
1126+ ) ;
1127+ }
1128+
1129+ #[ test]
1130+ fn test_package_specs_es6_deprecation ( ) {
1131+ let json = r#"
1132+ {
1133+ "name": "testrepo",
1134+ "sources": {
1135+ "dir": "src",
1136+ "subdirs": true
1137+ },
1138+ "package-specs": [
1139+ {
1140+ "module": "es6",
1141+ "in-source": true
1142+ }
1143+ ],
1144+ "suffix": ".mjs"
1145+ }
1146+ "# ;
1147+
1148+ let config = Config :: new_from_json_string ( json) . expect ( "a valid json string" ) ;
1149+ assert_eq ! ( config. get_deprecations( ) , [ DeprecationWarning :: PackageSpecsEs6 ] ) ;
1150+ }
1151+
10841152 #[ test]
10851153 fn test_unknown_fields_are_collected ( ) {
10861154 let json = r#"
0 commit comments