diff --git a/crates/swc_ecma_preset_env/scripts/transform-data-gen.js b/crates/swc_ecma_preset_env/scripts/transform-data-gen.js new file mode 100644 index 000000000000..4720505a6011 --- /dev/null +++ b/crates/swc_ecma_preset_env/scripts/transform-data-gen.js @@ -0,0 +1,12 @@ +const fs = require("fs"); +const path = require("path"); +const data = require("@babel/compat-data/plugins"); + +const transform_data_json = path.join( + __dirname, + "..", + "src", + "transform_data.json" +); + +fs.writeFileSync(transform_data_json, JSON.stringify(data, null, 4) + "\n"); diff --git a/crates/swc_ecma_preset_env/src/lib.rs b/crates/swc_ecma_preset_env/src/lib.rs index 6ebc981d396c..e94b833b4112 100644 --- a/crates/swc_ecma_preset_env/src/lib.rs +++ b/crates/swc_ecma_preset_env/src/lib.rs @@ -85,12 +85,14 @@ where // Proposals - // ES2021 + // ES2022 let pass = add!( pass, ClassProperties, es2022::class_properties(es2022::class_properties::Config { loose }) ); + let pass = add!(pass, ClassStaticBlock, es2022::static_blocks()); + let pass = add!(pass, PrivatePropertyInObject, es2022::private_in_object()); // ES2021 let pass = add!( diff --git a/crates/swc_ecma_preset_env/src/transform_data.json b/crates/swc_ecma_preset_env/src/transform_data.json index 825ed49f9e29..698a8495e579 100644 --- a/crates/swc_ecma_preset_env/src/transform_data.json +++ b/crates/swc_ecma_preset_env/src/transform_data.json @@ -1,4 +1,21 @@ { + "proposal-class-static-block": { + "chrome": "94", + "opera": "80", + "edge": "94", + "firefox": "93", + "node": "16.11" + }, + "proposal-private-property-in-object": { + "chrome": "91", + "opera": "77", + "edge": "91", + "firefox": "90", + "safari": "15", + "node": "16.9", + "ios": "15", + "electron": "13.0" + }, "proposal-class-properties": { "chrome": "74", "opera": "62", @@ -6,6 +23,7 @@ "firefox": "90", "safari": "14.1", "node": "12", + "ios": "15", "samsung": "11", "electron": "6.0" }, @@ -16,6 +34,8 @@ "firefox": "90", "safari": "15", "node": "14.6", + "ios": "15", + "samsung": "14", "electron": "10.0" }, "proposal-numeric-separator": { @@ -37,6 +57,7 @@ "safari": "14", "node": "15", "ios": "14", + "samsung": "14", "electron": "10.0" }, "proposal-nullish-coalescing-operator": { @@ -51,9 +72,14 @@ "electron": "8.0" }, "proposal-optional-chaining": { + "chrome": "91", + "opera": "77", + "edge": "91", "firefox": "74", "safari": "13.1", - "ios": "13.4" + "node": "16.9", + "ios": "13.4", + "electron": "13.0" }, "proposal-json-strings": { "chrome": "66", @@ -82,9 +108,7 @@ "opera": "36", "edge": "18", "firefox": "53", - "safari": "10", "node": "6", - "ios": "10", "samsung": "5", "electron": "0.37" }, @@ -370,7 +394,7 @@ "chrome": "46", "opera": "33", "edge": "14", - "firefox": "45", + "firefox": "41", "safari": "10", "node": "5", "ios": "10", diff --git a/crates/swc_ecma_preset_env/src/transform_data.rs b/crates/swc_ecma_preset_env/src/transform_data.rs index 2d3480e7cfe2..8dfba6ec91f2 100644 --- a/crates/swc_ecma_preset_env/src/transform_data.rs +++ b/crates/swc_ecma_preset_env/src/transform_data.rs @@ -137,6 +137,12 @@ pub enum Feature { /// `proposal-private-methods` PrivateMethods, + /// `proposal-class-static-block` + ClassStaticBlock, + + /// `proposal-private-property-in-object` + PrivatePropertyInObject, + /// `transform-unicode-escapes` UnicodeEscapes, diff --git a/crates/swc_ecma_preset_env/src/transform_data_bugfixes.json b/crates/swc_ecma_preset_env/src/transform_data_bugfixes.json index 8af58d1fed29..76e7b95430d4 100644 --- a/crates/swc_ecma_preset_env/src/transform_data_bugfixes.json +++ b/crates/swc_ecma_preset_env/src/transform_data_bugfixes.json @@ -1,79 +1,79 @@ { - "transform-async-to-generator": { - "chrome": "55", - "opera": "42", - "edge": "15", - "firefox": "52", - "safari": "10.1", - "node": "7.6", - "ios": "10.3", - "samsung": "6", - "electron": "1.6" - }, - "bugfix/transform-async-arrows-in-class": { - "chrome": "55", - "opera": "42", - "edge": "15", - "firefox": "52", - "safari": "11", - "node": "7.6", - "ios": "11", - "samsung": "6", - "electron": "1.6" - }, - "transform-parameters": { - "chrome": "49", - "opera": "36", - "edge": "15", - "firefox": "53", - "safari": "10", - "node": "6", - "ios": "10", - "samsung": "5", - "electron": "0.37" - }, - "bugfix/transform-edge-default-parameters": { - "chrome": "49", - "opera": "36", - "edge": "18", - "firefox": "52", - "safari": "10", - "node": "6", - "ios": "10", - "samsung": "5", - "electron": "0.37" - }, - "transform-block-scoping": { - "chrome": "49", - "opera": "36", - "edge": "14", - "firefox": "51", - "safari": "10", - "node": "6", - "ios": "10", - "samsung": "5", - "electron": "0.37" - }, - "transform-template-literals": { - "chrome": "41", - "opera": "28", - "edge": "13", - "firefox": "34", - "safari": "9", - "node": "4", - "ios": "9", - "samsung": "3.4", - "electron": "0.21" - }, - "bugfix/transform-tagged-template-caching": { - "chrome": "41", - "opera": "28", - "edge": "12", - "firefox": "34", - "safari": "13", - "node": "4", - "ios": "13", - "samsung": "3.4", - "electron": "0.21" - } -} \ No newline at end of file + "transform-async-to-generator": { + "chrome": "55", + "opera": "42", + "edge": "15", + "firefox": "52", + "safari": "10.1", + "node": "7.6", + "ios": "10.3", + "samsung": "6", + "electron": "1.6" + }, + "bugfix/transform-async-arrows-in-class": { + "chrome": "55", + "opera": "42", + "edge": "15", + "firefox": "52", + "safari": "11", + "node": "7.6", + "ios": "11", + "samsung": "6", + "electron": "1.6" + }, + "transform-parameters": { + "chrome": "49", + "opera": "36", + "edge": "15", + "firefox": "53", + "safari": "10", + "node": "6", + "ios": "10", + "samsung": "5", + "electron": "0.37" + }, + "bugfix/transform-edge-default-parameters": { + "chrome": "49", + "opera": "36", + "edge": "18", + "firefox": "52", + "safari": "10", + "node": "6", + "ios": "10", + "samsung": "5", + "electron": "0.37" + }, + "transform-block-scoping": { + "chrome": "49", + "opera": "36", + "edge": "14", + "firefox": "51", + "safari": "10", + "node": "6", + "ios": "10", + "samsung": "5", + "electron": "0.37" + }, + "transform-template-literals": { + "chrome": "41", + "opera": "28", + "edge": "13", + "firefox": "34", + "safari": "9", + "node": "4", + "ios": "9", + "samsung": "3.4", + "electron": "0.21" + }, + "bugfix/transform-tagged-template-caching": { + "chrome": "41", + "opera": "28", + "edge": "12", + "firefox": "34", + "safari": "13", + "node": "4", + "ios": "13", + "samsung": "3.4", + "electron": "0.21" + } +} diff --git a/package.json b/package.json index 8269e19eb0ce..49c52418c6ae 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "version": "napi version -p scripts/npm" }, "devDependencies": { + "@babel/compat-data": "^7.16.4", "@babel/core": "^7.13.16", "@babel/plugin-proposal-class-properties": "^7.13.0", "@babel/plugin-proposal-decorators": "^7.13.15", diff --git a/yarn.lock b/yarn.lock index ba9166c1e559..dfe94d268276 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21,6 +21,11 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.14.9.tgz#ac7996ceaafcf8f410119c8af0d1db4cf914a210" integrity sha512-p3QjZmMGHDGdpcwEYYWu7i7oJShJvtgMjJeb0W95PPhSm++3lm8YXYOh45Y6iCN9PkZLTZ7CIX5nFrp7pw7TXw== +"@babel/compat-data@^7.16.4": + version "7.16.4" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.4.tgz#081d6bbc336ec5c2435c6346b2ae1fb98b5ac68e" + integrity sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q== + "@babel/core@^7.1.0", "@babel/core@^7.13.16", "@babel/core@^7.7.2", "@babel/core@^7.7.5": version "7.14.8" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.14.8.tgz#20cdf7c84b5d86d83fac8710a8bc605a7ba3f010"