From 40ae6568a45bdeb6e25bc4f4ef180ca9894a0ecd Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Sun, 13 Jan 2019 08:32:33 -0600 Subject: [PATCH] Add support for proposal-json-strings in preset-env (#9323) --- packages/babel-preset-env/data/built-ins.json | 35 ++++++++++++++++++- .../babel-preset-env/data/plugin-features.js | 2 +- packages/babel-preset-env/data/plugins.json | 10 +++++- packages/babel-preset-env/package.json | 3 +- .../babel-preset-env/scripts/build-data.js | 2 +- .../babel-preset-env/src/available-plugins.js | 1 + 6 files changed, 48 insertions(+), 5 deletions(-) diff --git a/packages/babel-preset-env/data/built-ins.json b/packages/babel-preset-env/data/built-ins.json index d6c82dccc9..32897b6552 100644 --- a/packages/babel-preset-env/data/built-ins.json +++ b/packages/babel-preset-env/data/built-ins.json @@ -19,6 +19,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.fill": { @@ -41,6 +42,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.find": { @@ -73,6 +75,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.from": { @@ -105,6 +108,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.is-array": { @@ -117,6 +121,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.iterator": { @@ -139,6 +144,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.map": { @@ -151,6 +157,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.of": { @@ -173,6 +180,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.reduce-right": { @@ -185,6 +193,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.some": { @@ -197,6 +206,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.array.sort": { @@ -230,6 +240,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.date.to-iso-string": { @@ -242,6 +253,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.date.to-json": { @@ -276,6 +288,7 @@ "ie": "10", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.function.bind": { @@ -287,7 +300,8 @@ "node": "0.10", "ie": "9", "android": "4.0", - "ios": "7" + "ios": "7", + "phantom": "2" }, "es6.function.has-instance": { "chrome": "51", @@ -308,6 +322,7 @@ "node": "0.12", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.map": { @@ -611,6 +626,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es7.object.define-getter": { @@ -643,6 +659,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.object.define-properties": { @@ -655,6 +672,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es7.object.entries": { @@ -1075,6 +1093,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.big": { @@ -1085,6 +1104,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.blink": { @@ -1095,6 +1115,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.bold": { @@ -1105,6 +1126,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.code-point-at": { @@ -1135,6 +1157,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.fontcolor": { @@ -1145,6 +1168,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.fontsize": { @@ -1155,6 +1179,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.from-code-point": { @@ -1185,6 +1210,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.iterator": { @@ -1205,6 +1231,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es7.string.pad-start": { @@ -1255,6 +1282,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.starts-with": { @@ -1275,6 +1303,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.sub": { @@ -1285,6 +1314,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.sup": { @@ -1295,6 +1325,7 @@ "node": "0.12", "android": "4.0", "ios": "7", + "phantom": "2", "electron": "1.1" }, "es6.string.trim": { @@ -1307,6 +1338,7 @@ "ie": "9", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.typed.array-buffer": { @@ -1329,6 +1361,7 @@ "ie": "10", "android": "4.0", "ios": "6", + "phantom": "2", "electron": "1.1" }, "es6.typed.int8-array": { diff --git a/packages/babel-preset-env/data/plugin-features.js b/packages/babel-preset-env/data/plugin-features.js index 9f1e10324a..4fcdf4a6b6 100644 --- a/packages/babel-preset-env/data/plugin-features.js +++ b/packages/babel-preset-env/data/plugin-features.js @@ -96,7 +96,7 @@ const es = { "proposal-object-rest-spread": "object rest/spread properties", "proposal-unicode-property-regex": "RegExp Unicode Property Escapes", - "proposal-json-strings": "", // Awaiting mapping in compat-table + "proposal-json-strings": "JSON superset", "proposal-optional-catch-binding": "optional catch binding", }; diff --git a/packages/babel-preset-env/data/plugins.json b/packages/babel-preset-env/data/plugins.json index b24d39d456..a4c706b3f5 100644 --- a/packages/babel-preset-env/data/plugins.json +++ b/packages/babel-preset-env/data/plugins.json @@ -253,7 +253,15 @@ "opera": "51", "electron": "3" }, - "proposal-json-strings": {}, + "proposal-json-strings": { + "chrome": "66", + "firefox": "62", + "safari": "12", + "node": "10.13", + "ios": "12", + "opera": "53", + "electron": "3" + }, "proposal-optional-catch-binding": { "chrome": "66", "firefox": "58", diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index 531f5af533..3cf0f539c1 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -22,6 +22,7 @@ "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", "@babel/plugin-proposal-unicode-property-regex": "^7.2.0", "@babel/plugin-syntax-async-generators": "^7.2.0", + "@babel/plugin-syntax-json-strings": "^7.2.0", "@babel/plugin-syntax-object-rest-spread": "^7.2.0", "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", "@babel/plugin-transform-arrow-functions": "^7.2.0", @@ -65,7 +66,7 @@ "@babel/helper-fixtures": "^7.2.0", "@babel/helper-plugin-test-runner": "^7.0.0", "caniuse-db": "1.0.30000851", - "compat-table": "kangax/compat-table#7655c84581184806d4f94ef97fbaac7abd5852d8", + "compat-table": "kangax/compat-table#29db20b301e3351d036890d4a72d3b25980cd70d", "electron-to-chromium": "1.3.79" } } diff --git a/packages/babel-preset-env/scripts/build-data.js b/packages/babel-preset-env/scripts/build-data.js index 82288ac702..3706d8148a 100644 --- a/packages/babel-preset-env/scripts/build-data.js +++ b/packages/babel-preset-env/scripts/build-data.js @@ -192,7 +192,7 @@ const getLowestImplementedVersion = ({ features }, env) => { // only doing this for built-ins atm // // NOTE: when/if compat-table adds a babel7 key, we'll want to update this - if (!test.babel6 && isBuiltIn) { + if (!test.babel6corejs2 && isBuiltIn) { return "-1"; } diff --git a/packages/babel-preset-env/src/available-plugins.js b/packages/babel-preset-env/src/available-plugins.js index 559e5478a4..09d820f5c3 100644 --- a/packages/babel-preset-env/src/available-plugins.js +++ b/packages/babel-preset-env/src/available-plugins.js @@ -1,5 +1,6 @@ export default { "syntax-async-generators": require("@babel/plugin-syntax-async-generators"), + "syntax-json-strings": require("@babel/plugin-syntax-json-strings"), "syntax-object-rest-spread": require("@babel/plugin-syntax-object-rest-spread"), "syntax-optional-catch-binding": require("@babel/plugin-syntax-optional-catch-binding"), "transform-async-to-generator": require("@babel/plugin-transform-async-to-generator"),