@@ -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}
@@ -992,7 +1011,7 @@ pub mod tests {
9921011 },
9931012 "package-specs": [
9941013 {
995- "module": "es6 ",
1014+ "module": "esmodule ",
9961015 "in-source": true
9971016 }
9981017 ],
@@ -1017,7 +1036,7 @@ pub mod tests {
10171036 },
10181037 "package-specs": [
10191038 {
1020- "module": "es6 ",
1039+ "module": "esmodule ",
10211040 "in-source": true
10221041 }
10231042 ],
@@ -1042,7 +1061,7 @@ pub mod tests {
10421061 },
10431062 "package-specs": [
10441063 {
1045- "module": "es6 ",
1064+ "module": "esmodule ",
10461065 "in-source": true
10471066 }
10481067 ],
@@ -1067,7 +1086,7 @@ pub mod tests {
10671086 },
10681087 "package-specs": [
10691088 {
1070- "module": "es6 ",
1089+ "module": "esmodule ",
10711090 "in-source": true
10721091 }
10731092 ],
@@ -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#"
@@ -1150,7 +1218,7 @@ pub mod tests {
11501218 },
11511219 "package-specs": [
11521220 {
1153- "module": "es6 ",
1221+ "module": "esmodule ",
11541222 "in-source": true
11551223 }
11561224 ],
@@ -1185,7 +1253,7 @@ pub mod tests {
11851253 },
11861254 "package-specs": [
11871255 {
1188- "module": "es6 ",
1256+ "module": "esmodule ",
11891257 "in-source": true
11901258 }
11911259 ],
0 commit comments