Extract targets parser and compat data from preset-env (#10899)
* Extract targets parser and compat data from preset-env * Review by Jùnliàng * isItemRequired -> targetsSupported * Export isRequired
This commit is contained in:
315
packages/babel-compat-data/scripts/build-data.js
Normal file
315
packages/babel-compat-data/scripts/build-data.js
Normal file
@@ -0,0 +1,315 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const semver = require("semver");
|
||||
const flattenDeep = require("lodash/flattenDeep");
|
||||
const isEqual = require("lodash/isEqual");
|
||||
const mapValues = require("lodash/mapValues");
|
||||
const pickBy = require("lodash/pickBy");
|
||||
const { unreleasedLabels } = require("babel/helper-compilation-targets");
|
||||
const electronToChromiumVersions = require("electron-to-chromium").versions;
|
||||
|
||||
const electronToChromiumKeys = Object.keys(
|
||||
electronToChromiumVersions
|
||||
).reverse();
|
||||
|
||||
const chromiumToElectronMap = electronToChromiumKeys.reduce((all, electron) => {
|
||||
all[electronToChromiumVersions[electron]] = +electron;
|
||||
return all;
|
||||
}, {});
|
||||
const chromiumToElectronVersions = Object.keys(chromiumToElectronMap);
|
||||
|
||||
const findClosestElectronVersion = targetVersion => {
|
||||
const chromiumVersionsLength = chromiumToElectronVersions.length;
|
||||
const maxChromium = +chromiumToElectronVersions[chromiumVersionsLength - 1];
|
||||
if (targetVersion > maxChromium) return null;
|
||||
|
||||
const closestChrome = chromiumToElectronVersions.find(
|
||||
version => targetVersion <= version
|
||||
);
|
||||
return chromiumToElectronMap[closestChrome];
|
||||
};
|
||||
|
||||
const chromiumToElectron = chromium =>
|
||||
chromiumToElectronMap[chromium] || findClosestElectronVersion(chromium);
|
||||
|
||||
const renameTests = (tests, getName, category) =>
|
||||
tests.map(test =>
|
||||
Object.assign({}, test, { name: getName(test.name), category })
|
||||
);
|
||||
|
||||
// The following is adapted from compat-table:
|
||||
// https://github.com/kangax/compat-table/blob/gh-pages/build.js
|
||||
//
|
||||
// It parses and interpolates data so environments that "equal" other
|
||||
// environments (node4 and chrome45), as well as familial relationships (edge
|
||||
// and ie11) can be handled properly.
|
||||
|
||||
const envs = require("../build/compat-table/environments");
|
||||
|
||||
const byTestSuite = suite => browser => {
|
||||
return Array.isArray(browser.test_suites)
|
||||
? browser.test_suites.indexOf(suite) > -1
|
||||
: true;
|
||||
};
|
||||
|
||||
const compatSources = ["es5", "es6", "es2016plus", "esnext"].reduce(
|
||||
(result, source) => {
|
||||
const data = require(`../build/compat-table/data-${source}`);
|
||||
data.browsers = pickBy(envs, byTestSuite(source));
|
||||
result.push(data);
|
||||
return result;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const interpolateAllResults = (rawBrowsers, tests) => {
|
||||
const interpolateResults = res => {
|
||||
let browser;
|
||||
let prevBrowser;
|
||||
let result;
|
||||
let prevResult;
|
||||
let prevBid;
|
||||
|
||||
for (const bid in rawBrowsers) {
|
||||
// For browsers that are essentially equal to other browsers,
|
||||
// copy over the results.
|
||||
browser = rawBrowsers[bid];
|
||||
if (browser.equals && res[bid] === undefined) {
|
||||
result = res[browser.equals];
|
||||
res[bid] =
|
||||
browser.ignore_flagged && result === "flagged" ? false : result;
|
||||
// For each browser, check if the previous browser has the same
|
||||
// browser full name (e.g. Firefox) or family name (e.g. Chakra) as this one.
|
||||
} else if (
|
||||
prevBrowser &&
|
||||
(prevBrowser.full.replace(/,.+$/, "") ===
|
||||
browser.full.replace(/,.+$/, "") ||
|
||||
(browser.family !== undefined &&
|
||||
prevBrowser.family === browser.family))
|
||||
) {
|
||||
// For each test, check if the previous browser has a result
|
||||
// that this browser lacks.
|
||||
result = res[bid];
|
||||
prevResult = res[prevBid];
|
||||
if (prevResult !== undefined && result === undefined) {
|
||||
res[bid] = prevResult;
|
||||
}
|
||||
}
|
||||
prevBrowser = browser;
|
||||
prevBid = bid;
|
||||
}
|
||||
};
|
||||
|
||||
// Now print the results.
|
||||
tests.forEach(function(t) {
|
||||
// Calculate the result totals for tests which consist solely of subtests.
|
||||
if ("subtests" in t) {
|
||||
t.subtests.forEach(function(e) {
|
||||
interpolateResults(e.res);
|
||||
});
|
||||
} else {
|
||||
interpolateResults(t.res);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
compatSources.forEach(({ browsers, tests }) =>
|
||||
interpolateAllResults(browsers, tests)
|
||||
);
|
||||
|
||||
// End of compat-table code adaptation
|
||||
|
||||
const environments = [
|
||||
"chrome",
|
||||
"opera",
|
||||
"edge",
|
||||
"firefox",
|
||||
"safari",
|
||||
"node",
|
||||
"ie",
|
||||
"android",
|
||||
"ios",
|
||||
"phantom",
|
||||
"samsung",
|
||||
];
|
||||
|
||||
const compatibilityTests = flattenDeep(
|
||||
compatSources.map(data =>
|
||||
data.tests.map(test => {
|
||||
return test.subtests
|
||||
? [
|
||||
test,
|
||||
renameTests(
|
||||
test.subtests,
|
||||
name => test.name + " / " + name,
|
||||
test.category
|
||||
),
|
||||
]
|
||||
: test;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
const getLowestImplementedVersion = ({ features }, env) => {
|
||||
const tests = compatibilityTests
|
||||
.filter(test => {
|
||||
return (
|
||||
features.indexOf(test.name) >= 0 ||
|
||||
// for features === ["DataView"]
|
||||
// it covers "DataView (Int8)" and "DataView (UInt8)"
|
||||
(features.length === 1 && test.name.indexOf(features[0]) === 0)
|
||||
);
|
||||
})
|
||||
.reduce((result, test) => {
|
||||
if (!test.subtests) {
|
||||
result.push({
|
||||
name: test.name,
|
||||
res: test.res,
|
||||
});
|
||||
} else {
|
||||
test.subtests.forEach(subtest =>
|
||||
result.push({
|
||||
name: `${test.name}/${subtest.name}`,
|
||||
res: subtest.res,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
const unreleasedLabelForEnv = unreleasedLabels[env];
|
||||
const envTests = tests.map(({ res: test }, i) => {
|
||||
const reportedVersions = Object.keys(test)
|
||||
.filter(t => t.startsWith(env))
|
||||
.map(t => {
|
||||
const version = t.replace(/_/g, ".").replace(env, "");
|
||||
return {
|
||||
version,
|
||||
semver: semver.coerce(version) || version,
|
||||
// Babel assumes strict mode
|
||||
implements: tests[i].res[t] === true || tests[i].res[t] === "strict",
|
||||
};
|
||||
})
|
||||
// version must be label from the unreleasedLabels (like tp) or number.
|
||||
.filter(
|
||||
version =>
|
||||
unreleasedLabelForEnv === version.version ||
|
||||
!isNaN(parseFloat(version.version))
|
||||
)
|
||||
// Sort in desc order, with unreleasedLabelForEnv coming last.
|
||||
.sort(({ semver: av }, { semver: bv }) => {
|
||||
if (av === unreleasedLabelForEnv) return -1;
|
||||
if (bv === unreleasedLabelForEnv) return 1;
|
||||
if (semver.gt(av, bv)) return -1;
|
||||
if (semver.gt(bv, av)) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Find the lowest version such that all higher versions implement it.
|
||||
// Eg, given { chrome70: true, chrome60: false, chrome50: true }, the
|
||||
// lowest version is chrome70, not chrome50.
|
||||
let lowest = null;
|
||||
for (const version of reportedVersions) {
|
||||
if (!version.implements) {
|
||||
break;
|
||||
}
|
||||
lowest = version;
|
||||
}
|
||||
return lowest;
|
||||
});
|
||||
|
||||
const envFiltered = envTests.filter(t => t);
|
||||
if (envTests.length > envFiltered.length || envTests.length === 0) {
|
||||
// envTests.forEach((test, i) => {
|
||||
// if (!test) {
|
||||
// // print unsupported features
|
||||
// if (env === 'node') {
|
||||
// console.log(`ENV(${env}): ${tests[i].name}`);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
return null;
|
||||
}
|
||||
|
||||
return envFiltered.reduce((a, b) => {
|
||||
if (
|
||||
a.semver === unreleasedLabelForEnv ||
|
||||
b.semver === unreleasedLabelForEnv
|
||||
) {
|
||||
return unreleasedLabelForEnv;
|
||||
}
|
||||
|
||||
return semver.lt(a.semver, b.semver) ? b : a;
|
||||
});
|
||||
};
|
||||
|
||||
const generateData = (environments, features) => {
|
||||
return mapValues(features, options => {
|
||||
if (!options.features) {
|
||||
options = {
|
||||
features: [options],
|
||||
};
|
||||
}
|
||||
|
||||
const plugin = {};
|
||||
|
||||
environments.forEach(env => {
|
||||
const version = getLowestImplementedVersion(options, env);
|
||||
|
||||
if (version !== null) {
|
||||
const versionString = version.version;
|
||||
|
||||
// NOTE(bng): A number of environments in compat-table changed to
|
||||
// include a trailing zero (node10 -> node10_0), so for now stripping
|
||||
// it to be consistent
|
||||
plugin[env] = versionString.endsWith(".0")
|
||||
? versionString.slice(0, -2)
|
||||
: versionString;
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.chrome) {
|
||||
// add opera
|
||||
if (plugin.chrome >= 28) {
|
||||
plugin.opera = (plugin.chrome - 13).toString();
|
||||
} else if (plugin.chrome === 5) {
|
||||
plugin.opera = "12";
|
||||
}
|
||||
|
||||
// add electron
|
||||
const electronVersion = chromiumToElectron(plugin.chrome);
|
||||
if (electronVersion) {
|
||||
plugin.electron = electronVersion.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return plugin;
|
||||
});
|
||||
};
|
||||
|
||||
["plugin", "corejs2-built-in"].forEach(target => {
|
||||
const newData = generateData(
|
||||
environments,
|
||||
require(`./data/${target}-features`)
|
||||
);
|
||||
const dataPath = path.join(__dirname, `../data/${target}s.json`);
|
||||
|
||||
if (process.argv[2] === "--check") {
|
||||
const currentData = require(dataPath);
|
||||
|
||||
if (!isEqual(currentData, newData)) {
|
||||
console.error(
|
||||
"The newly generated plugin/built-in data does not match the current " +
|
||||
"files. Re-run `npm run build-data`."
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
fs.writeFileSync(dataPath, `${JSON.stringify(newData, null, 2)}\n`);
|
||||
});
|
||||
36
packages/babel-compat-data/scripts/build-modules-support.js
Normal file
36
packages/babel-compat-data/scripts/build-modules-support.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const moduleSupport = require("caniuse-db/features-json/es6-module.json");
|
||||
|
||||
const skipList = new Set(["android", "samsung"]);
|
||||
const acceptedWithCaveats = new Set(["safari", "ios_saf"]);
|
||||
|
||||
const { stats } = moduleSupport;
|
||||
|
||||
const allowedBrowsers = {};
|
||||
|
||||
Object.keys(stats).forEach(browser => {
|
||||
if (!skipList.has(browser)) {
|
||||
const browserVersions = stats[browser];
|
||||
const allowedVersions = Object.keys(browserVersions)
|
||||
.filter(value => {
|
||||
// Edge 16/17 are marked as "y #6"
|
||||
return acceptedWithCaveats.has(browser)
|
||||
? browserVersions[value][0] === "a"
|
||||
: browserVersions[value].startsWith("y");
|
||||
})
|
||||
.sort((a, b) => a - b);
|
||||
|
||||
if (allowedVersions[0] !== undefined) {
|
||||
// Handle cases where caniuse specifies version as: "11.0-11.2"
|
||||
allowedBrowsers[browser] = allowedVersions[0].split("-")[0];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const dataPath = path.join(__dirname, "../data/built-in-modules.json");
|
||||
const data = {
|
||||
"es6.module": allowedBrowsers,
|
||||
};
|
||||
fs.writeFileSync(dataPath, `${JSON.stringify(data, null, 2)}\n`);
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const overlappingPlugins = require("./data/overlapping-plugins");
|
||||
|
||||
fs.writeFileSync(
|
||||
__dirname + "/../data/overlapping-plugins.json",
|
||||
JSON.stringify(overlappingPlugins, replacer, 2)
|
||||
);
|
||||
|
||||
function replacer(key, val) {
|
||||
if (val instanceof Set) return Array.from(val);
|
||||
if (val instanceof Map) return Object.fromEntries(val);
|
||||
return val;
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
const typedArrayMethods = [
|
||||
"typed arrays / %TypedArray%.from",
|
||||
"typed arrays / %TypedArray%.of",
|
||||
"typed arrays / %TypedArray%.prototype.subarray",
|
||||
"typed arrays / %TypedArray%.prototype.join",
|
||||
"typed arrays / %TypedArray%.prototype.indexOf",
|
||||
"typed arrays / %TypedArray%.prototype.lastIndexOf",
|
||||
"typed arrays / %TypedArray%.prototype.slice",
|
||||
"typed arrays / %TypedArray%.prototype.every",
|
||||
"typed arrays / %TypedArray%.prototype.filter",
|
||||
"typed arrays / %TypedArray%.prototype.forEach",
|
||||
"typed arrays / %TypedArray%.prototype.map",
|
||||
"typed arrays / %TypedArray%.prototype.reduce",
|
||||
"typed arrays / %TypedArray%.prototype.reduceRight",
|
||||
"typed arrays / %TypedArray%.prototype.reverse",
|
||||
"typed arrays / %TypedArray%.prototype.some",
|
||||
"typed arrays / %TypedArray%.prototype.sort",
|
||||
"typed arrays / %TypedArray%.prototype.copyWithin",
|
||||
"typed arrays / %TypedArray%.prototype.find",
|
||||
"typed arrays / %TypedArray%.prototype.findIndex",
|
||||
"typed arrays / %TypedArray%.prototype.fill",
|
||||
"typed arrays / %TypedArray%.prototype.keys",
|
||||
"typed arrays / %TypedArray%.prototype.values",
|
||||
"typed arrays / %TypedArray%.prototype.entries",
|
||||
"typed arrays / %TypedArray%.prototype[Symbol.iterator]",
|
||||
"typed arrays / %TypedArray%[Symbol.species]",
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
// compat-table missing babel6 mapping
|
||||
// "es6.array.concat": {
|
||||
// features: [
|
||||
// "well-known symbols / Symbol.isConcatSpreadable",
|
||||
// "well-known symbols / Symbol.species, Array.prototype.concat",
|
||||
// ]
|
||||
// },
|
||||
"es6.array.copy-within":
|
||||
"Array.prototype methods / Array.prototype.copyWithin",
|
||||
"es6.array.every": "Array methods / Array.prototype.every",
|
||||
"es6.array.fill": "Array.prototype methods / Array.prototype.fill",
|
||||
"es6.array.filter": {
|
||||
features: [
|
||||
"Array methods / Array.prototype.filter",
|
||||
// compat-table missing babel6 mapping
|
||||
// "well-known symbols / Symbol.species, Array.prototype.filter",
|
||||
],
|
||||
},
|
||||
"es6.array.find": "Array.prototype methods / Array.prototype.find",
|
||||
"es6.array.find-index": "Array.prototype methods / Array.prototype.findIndex",
|
||||
"es7.array.flat-map":
|
||||
"Array.prototype.{flat, flatMap} / Array.prototype.flatMap",
|
||||
"es6.array.for-each": "Array methods / Array.prototype.forEach",
|
||||
"es6.array.from": "Array static methods / Array.from",
|
||||
"es7.array.includes": "Array.prototype.includes",
|
||||
"es6.array.index-of": "Array methods / Array.prototype.indexOf",
|
||||
"es6.array.is-array": "Array methods / Array.isArray",
|
||||
// "es.array.join": "", required tests for that
|
||||
"es6.array.iterator": {
|
||||
features: [
|
||||
"Array.prototype methods / Array.prototype.keys",
|
||||
// can use Symbol.iterator, not implemented in many environments
|
||||
// "Array.prototype methods / Array.prototype.values",
|
||||
"Array.prototype methods / Array.prototype.entries",
|
||||
],
|
||||
},
|
||||
"es6.array.last-index-of": "Array methods / Array.prototype.lastIndexOf",
|
||||
"es6.array.map": {
|
||||
features: [
|
||||
"Array methods / Array.prototype.map",
|
||||
// compat-table missing babel6 mapping
|
||||
// "well-known symbols / Symbol.species, Array.prototype.map",
|
||||
],
|
||||
},
|
||||
"es6.array.of": "Array static methods / Array.of",
|
||||
"es6.array.reduce": "Array methods / Array.prototype.reduce",
|
||||
"es6.array.reduce-right": "Array methods / Array.prototype.reduceRight",
|
||||
// compat-table missing babel6 mapping
|
||||
// "es6.array.slice": "well-known symbols / Symbol.species, Array.prototype.slice",
|
||||
"es6.array.some": "Array methods / Array.prototype.some",
|
||||
"es6.array.sort": "Array methods / Array.prototype.sort",
|
||||
"es6.array.species": "Array static methods / Array[Symbol.species]",
|
||||
// compat-table missing babel6 mapping
|
||||
//"es6.array.splice": "well-known symbols / Symbol.species, Array.prototype.splice",
|
||||
|
||||
"es6.date.now": "Date methods / Date.now",
|
||||
"es6.date.to-iso-string": "Date methods / Date.prototype.toISOString",
|
||||
"es6.date.to-json": "Date methods / Date.prototype.toJSON",
|
||||
"es6.date.to-primitive": "Date.prototype[Symbol.toPrimitive]",
|
||||
"es6.date.to-string": "miscellaneous / Invalid Date",
|
||||
|
||||
"es6.function.bind": "Function.prototype.bind",
|
||||
"es6.function.has-instance": "well-known symbols / Symbol.hasInstance",
|
||||
"es6.function.name": {
|
||||
features: [
|
||||
'function "name" property / function statements',
|
||||
'function "name" property / function expressions',
|
||||
],
|
||||
},
|
||||
|
||||
// This is explicit to prevent Map-related proposals (like
|
||||
// Map.prototype.upsert) from being included
|
||||
"es6.map": {
|
||||
features: [
|
||||
"Map / basic functionality",
|
||||
"Map / constructor arguments",
|
||||
"Map / constructor requires new",
|
||||
"Map / constructor accepts null",
|
||||
"Map / constructor invokes set",
|
||||
"Map / iterator closing",
|
||||
"Map / Map.prototype.add returns this",
|
||||
"Map / -0 key converts to +0",
|
||||
"Map / Map.prototype.size",
|
||||
"Map / Map.prototype.delete",
|
||||
"Map / Map.prototype.clear",
|
||||
"Map / Map.prototype.forEach",
|
||||
"Map / Map.prototype.keys",
|
||||
"Map / Map.prototype.values",
|
||||
"Map / Map.prototype.entries",
|
||||
"Map / Map.prototype[Symbol.iterator]",
|
||||
"Map / Map.prototype isn't an instance",
|
||||
"Map / Map iterator prototype chain",
|
||||
"Map / Map[Symbol.species]",
|
||||
],
|
||||
},
|
||||
|
||||
"es6.math.acosh": "Math methods / Math.acosh",
|
||||
"es6.math.asinh": "Math methods / Math.asinh",
|
||||
"es6.math.atanh": "Math methods / Math.atanh",
|
||||
"es6.math.cbrt": "Math methods / Math.cbrt",
|
||||
"es6.math.clz32": "Math methods / Math.clz32",
|
||||
"es6.math.cosh": "Math methods / Math.cosh",
|
||||
"es6.math.expm1": "Math methods / Math.expm1",
|
||||
"es6.math.fround": "Math methods / Math.fround",
|
||||
"es6.math.hypot": "Math methods / Math.hypot",
|
||||
"es6.math.imul": "Math methods / Math.imul",
|
||||
"es6.math.log1p": "Math methods / Math.log1p",
|
||||
"es6.math.log10": "Math methods / Math.log10",
|
||||
"es6.math.log2": "Math methods / Math.log2",
|
||||
"es6.math.sign": "Math methods / Math.sign",
|
||||
"es6.math.sinh": "Math methods / Math.sinh",
|
||||
"es6.math.tanh": "Math methods / Math.tanh",
|
||||
"es6.math.trunc": "Math methods / Math.trunc",
|
||||
|
||||
"es6.number.constructor": {
|
||||
features: [
|
||||
"octal and binary literals / octal supported by Number()",
|
||||
"octal and binary literals / binary supported by Number()",
|
||||
],
|
||||
},
|
||||
"es6.number.epsilon": "Number properties / Number.EPSILON",
|
||||
"es6.number.is-finite": "Number properties / Number.isFinite",
|
||||
"es6.number.is-integer": "Number properties / Number.isInteger",
|
||||
"es6.number.is-nan": "Number properties / Number.isNaN",
|
||||
"es6.number.is-safe-integer": "Number properties / Number.isSafeInteger",
|
||||
"es6.number.max-safe-integer": "Number properties / Number.MAX_SAFE_INTEGER",
|
||||
"es6.number.min-safe-integer": "Number properties / Number.MIN_SAFE_INTEGER",
|
||||
"es6.number.parse-float": "Number properties / Number.parseFloat",
|
||||
"es6.number.parse-int": "Number properties / Number.parseInt",
|
||||
|
||||
"es6.object.assign": {
|
||||
features: ["Object static methods / Object.assign", "Symbol"],
|
||||
},
|
||||
"es6.object.create": "Object static methods / Object.create",
|
||||
"es7.object.define-getter": {
|
||||
features: [
|
||||
"Object.prototype getter/setter methods / __defineGetter__",
|
||||
"Object.prototype getter/setter methods / __defineGetter__, symbols",
|
||||
"Object.prototype getter/setter methods / __defineGetter__, ToObject(this)",
|
||||
],
|
||||
},
|
||||
"es7.object.define-setter": {
|
||||
features: [
|
||||
"Object.prototype getter/setter methods / __defineSetter__",
|
||||
"Object.prototype getter/setter methods / __defineSetter__, symbols",
|
||||
"Object.prototype getter/setter methods / __defineSetter__, ToObject(this)",
|
||||
],
|
||||
},
|
||||
"es6.object.define-property": "Object static methods / Object.defineProperty",
|
||||
"es6.object.define-properties":
|
||||
"Object static methods / Object.defineProperties",
|
||||
"es7.object.entries": "Object static methods / Object.entries",
|
||||
"es6.object.freeze":
|
||||
"Object static methods accept primitives / Object.freeze",
|
||||
"es6.object.get-own-property-descriptor":
|
||||
"Object static methods accept primitives / Object.getOwnPropertyDescriptor",
|
||||
"es7.object.get-own-property-descriptors":
|
||||
"Object static methods / Object.getOwnPropertyDescriptors",
|
||||
"es6.object.get-own-property-names":
|
||||
"Object static methods accept primitives / Object.getOwnPropertyNames",
|
||||
"es6.object.get-prototype-of":
|
||||
"Object static methods accept primitives / Object.getPrototypeOf",
|
||||
"es7.object.lookup-getter": {
|
||||
features: [
|
||||
"Object.prototype getter/setter methods / __lookupGetter__",
|
||||
"Object.prototype getter/setter methods / __lookupGetter__, prototype chain",
|
||||
"Object.prototype getter/setter methods / __lookupGetter__, symbols",
|
||||
"Object.prototype getter/setter methods / __lookupGetter__, ToObject(this)",
|
||||
"Object.prototype getter/setter methods / __lookupGetter__, data properties can shadow accessors",
|
||||
],
|
||||
},
|
||||
"es7.object.lookup-setter": {
|
||||
features: [
|
||||
"Object.prototype getter/setter methods / __lookupSetter__",
|
||||
"Object.prototype getter/setter methods / __lookupSetter__, prototype chain",
|
||||
"Object.prototype getter/setter methods / __lookupSetter__, symbols",
|
||||
"Object.prototype getter/setter methods / __lookupSetter__, ToObject(this)",
|
||||
"Object.prototype getter/setter methods / __lookupSetter__, data properties can shadow accessors",
|
||||
],
|
||||
},
|
||||
"es6.object.prevent-extensions":
|
||||
"Object static methods accept primitives / Object.preventExtensions",
|
||||
"es6.object.to-string": "well-known symbols / Symbol.toStringTag",
|
||||
"es6.object.is": "Object static methods / Object.is",
|
||||
"es6.object.is-frozen":
|
||||
"Object static methods accept primitives / Object.isFrozen",
|
||||
"es6.object.is-sealed":
|
||||
"Object static methods accept primitives / Object.isSealed",
|
||||
"es6.object.is-extensible":
|
||||
"Object static methods accept primitives / Object.isExtensible",
|
||||
"es6.object.keys": "Object static methods accept primitives / Object.keys",
|
||||
"es6.object.seal": "Object static methods accept primitives / Object.seal",
|
||||
"es6.object.set-prototype-of":
|
||||
"Object static methods / Object.setPrototypeOf",
|
||||
"es7.object.values": "Object static methods / Object.values",
|
||||
|
||||
"es6.promise": {
|
||||
features: [
|
||||
// required unhandled rejection tracking tests
|
||||
"Promise",
|
||||
"well-known symbols / Symbol.species, Promise.prototype.then",
|
||||
],
|
||||
},
|
||||
"es7.promise.finally": "Promise.prototype.finally",
|
||||
|
||||
"es6.reflect.apply": "Reflect / Reflect.apply",
|
||||
"es6.reflect.construct": "Reflect / Reflect.construct",
|
||||
"es6.reflect.define-property": "Reflect / Reflect.defineProperty",
|
||||
"es6.reflect.delete-property": "Reflect / Reflect.deleteProperty",
|
||||
"es6.reflect.get": "Reflect / Reflect.get",
|
||||
"es6.reflect.get-own-property-descriptor":
|
||||
"Reflect / Reflect.getOwnPropertyDescriptor",
|
||||
"es6.reflect.get-prototype-of": "Reflect / Reflect.getPrototypeOf",
|
||||
"es6.reflect.has": "Reflect / Reflect.has",
|
||||
"es6.reflect.is-extensible": "Reflect / Reflect.isExtensible",
|
||||
"es6.reflect.own-keys": "Reflect / Reflect.ownKeys",
|
||||
"es6.reflect.prevent-extensions": "Reflect / Reflect.preventExtensions",
|
||||
"es6.reflect.set": "Reflect / Reflect.set",
|
||||
"es6.reflect.set-prototype-of": "Reflect / Reflect.setPrototypeOf",
|
||||
|
||||
"es6.regexp.constructor": {
|
||||
features: [
|
||||
"miscellaneous / RegExp constructor can alter flags",
|
||||
"well-known symbols / Symbol.match, RegExp constructor",
|
||||
],
|
||||
},
|
||||
"es6.regexp.flags": "RegExp.prototype properties / RegExp.prototype.flags",
|
||||
"es6.regexp.match":
|
||||
"RegExp.prototype properties / RegExp.prototype[Symbol.match]",
|
||||
"es6.regexp.replace":
|
||||
"RegExp.prototype properties / RegExp.prototype[Symbol.replace]",
|
||||
"es6.regexp.split":
|
||||
"RegExp.prototype properties / RegExp.prototype[Symbol.split]",
|
||||
"es6.regexp.search":
|
||||
"RegExp.prototype properties / RegExp.prototype[Symbol.search]",
|
||||
"es6.regexp.to-string":
|
||||
'miscellaneous / RegExp.prototype.toString generic and uses "flags" property',
|
||||
|
||||
// This is explicit due to prevent the stage-1 Set proposals under the
|
||||
// category "Set methods" from being included.
|
||||
"es6.set": {
|
||||
features: [
|
||||
"Set / basic functionality",
|
||||
"Set / constructor arguments",
|
||||
"Set / constructor requires new",
|
||||
"Set / constructor accepts null",
|
||||
"Set / constructor invokes add",
|
||||
"Set / iterator closing",
|
||||
"Set / Set.prototype.add returns this",
|
||||
"Set / -0 key converts to +0",
|
||||
"Set / Set.prototype.size",
|
||||
"Set / Set.prototype.delete",
|
||||
"Set / Set.prototype.clear",
|
||||
"Set / Set.prototype.forEach",
|
||||
"Set / Set.prototype.keys",
|
||||
"Set / Set.prototype.values",
|
||||
"Set / Set.prototype.entries",
|
||||
"Set / Set.prototype[Symbol.iterator]",
|
||||
"Set / Set.prototype isn't an instance",
|
||||
"Set / Set iterator prototype chain",
|
||||
"Set / Set[Symbol.species]",
|
||||
],
|
||||
},
|
||||
|
||||
"es6.symbol": {
|
||||
features: [
|
||||
"Symbol",
|
||||
"Object static methods / Object.getOwnPropertySymbols",
|
||||
"well-known symbols / Symbol.hasInstance",
|
||||
"well-known symbols / Symbol.isConcatSpreadable",
|
||||
"well-known symbols / Symbol.iterator",
|
||||
"well-known symbols / Symbol.match",
|
||||
"well-known symbols / Symbol.replace",
|
||||
"well-known symbols / Symbol.search",
|
||||
"well-known symbols / Symbol.species",
|
||||
"well-known symbols / Symbol.split",
|
||||
"well-known symbols / Symbol.toPrimitive",
|
||||
"well-known symbols / Symbol.toStringTag",
|
||||
"well-known symbols / Symbol.unscopables",
|
||||
],
|
||||
},
|
||||
"es7.symbol.async-iterator": "Asynchronous Iterators",
|
||||
|
||||
"es6.string.anchor": "String.prototype HTML methods",
|
||||
"es6.string.big": "String.prototype HTML methods",
|
||||
"es6.string.blink": "String.prototype HTML methods",
|
||||
"es6.string.bold": "String.prototype HTML methods",
|
||||
"es6.string.code-point-at":
|
||||
"String.prototype methods / String.prototype.codePointAt",
|
||||
"es6.string.ends-with":
|
||||
"String.prototype methods / String.prototype.endsWith",
|
||||
"es6.string.fixed": "String.prototype HTML methods",
|
||||
"es6.string.fontcolor": "String.prototype HTML methods",
|
||||
"es6.string.fontsize": "String.prototype HTML methods",
|
||||
"es6.string.from-code-point": "String static methods / String.fromCodePoint",
|
||||
"es6.string.includes": "String.prototype methods / String.prototype.includes",
|
||||
"es6.string.italics": "String.prototype HTML methods",
|
||||
"es6.string.iterator":
|
||||
"String.prototype methods / String.prototype[Symbol.iterator]",
|
||||
"es6.string.link": "String.prototype HTML methods",
|
||||
// "String.prototype methods / String.prototype.normalize" not implemented
|
||||
"es7.string.pad-start": "String padding / String.prototype.padStart",
|
||||
"es7.string.pad-end": "String padding / String.prototype.padEnd",
|
||||
"es6.string.raw": "String static methods / String.raw",
|
||||
"es6.string.repeat": "String.prototype methods / String.prototype.repeat",
|
||||
"es6.string.small": "String.prototype HTML methods",
|
||||
"es6.string.starts-with":
|
||||
"String.prototype methods / String.prototype.startsWith",
|
||||
"es6.string.strike": "String.prototype HTML methods",
|
||||
"es6.string.sub": "String.prototype HTML methods",
|
||||
"es6.string.sup": "String.prototype HTML methods",
|
||||
"es6.string.trim": "String properties and methods / String.prototype.trim",
|
||||
"es7.string.trim-left": "string trimming / String.prototype.trimStart",
|
||||
"es7.string.trim-right": "string trimming / String.prototype.trimEnd",
|
||||
|
||||
"es6.typed.array-buffer": "typed arrays / ArrayBuffer[Symbol.species]",
|
||||
"es6.typed.data-view": "typed arrays / DataView",
|
||||
"es6.typed.int8-array": {
|
||||
features: ["typed arrays / Int8Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.uint8-array": {
|
||||
features: ["typed arrays / Uint8Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.uint8-clamped-array": {
|
||||
features: ["typed arrays / Uint8ClampedArray"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.int16-array": {
|
||||
features: ["typed arrays / Int16Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.uint16-array": {
|
||||
features: ["typed arrays / Uint16Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.int32-array": {
|
||||
features: ["typed arrays / Int32Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.uint32-array": {
|
||||
features: ["typed arrays / Uint32Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.float32-array": {
|
||||
features: ["typed arrays / Float32Array"].concat(typedArrayMethods),
|
||||
},
|
||||
"es6.typed.float64-array": {
|
||||
features: ["typed arrays / Float64Array"].concat(typedArrayMethods),
|
||||
},
|
||||
|
||||
"es6.weak-map": "WeakMap",
|
||||
|
||||
"es6.weak-set": "WeakSet",
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = new Map();
|
||||
|
||||
// async -> regenerator is better than async -> generator -> regenerator
|
||||
ifIncluded("transform-regenerator")
|
||||
// Temporarly disabled: https://github.com/babel/babel/issues/10678
|
||||
// .isUnnecessary("transform-async-to-generator");
|
||||
|
||||
function ifIncluded(name) {
|
||||
const set = new Set();
|
||||
module.exports.set(name, set);
|
||||
return {
|
||||
isUnnecessary(name) { set.add(name); return this; },
|
||||
};
|
||||
}
|
||||
103
packages/babel-compat-data/scripts/data/plugin-features.js
Normal file
103
packages/babel-compat-data/scripts/data/plugin-features.js
Normal file
@@ -0,0 +1,103 @@
|
||||
module.exports = {
|
||||
"transform-template-literals": {
|
||||
features: ["template literals"],
|
||||
},
|
||||
"transform-literals": {
|
||||
features: ["Unicode code point escapes"],
|
||||
},
|
||||
"transform-function-name": {
|
||||
features: ['function "name" property'],
|
||||
},
|
||||
"transform-arrow-functions": {
|
||||
features: ["arrow functions"],
|
||||
},
|
||||
"transform-block-scoped-functions": {
|
||||
features: ["block-level function declaration"],
|
||||
},
|
||||
"transform-classes": {
|
||||
features: ["class", "super"],
|
||||
},
|
||||
"transform-object-super": {
|
||||
features: ["super"],
|
||||
},
|
||||
"transform-shorthand-properties": {
|
||||
features: ["object literal extensions / shorthand properties"],
|
||||
},
|
||||
"transform-duplicate-keys": {
|
||||
features: ["miscellaneous / duplicate property names in strict mode"],
|
||||
},
|
||||
"transform-computed-properties": {
|
||||
features: ["object literal extensions / computed properties"],
|
||||
},
|
||||
"transform-for-of": {
|
||||
features: ["for..of loops"],
|
||||
},
|
||||
"transform-sticky-regex": {
|
||||
features: [
|
||||
'RegExp "y" and "u" flags / "y" flag, lastIndex',
|
||||
'RegExp "y" and "u" flags / "y" flag',
|
||||
],
|
||||
},
|
||||
|
||||
// We want to apply this prior to unicode regex so that "." and "u"
|
||||
// are properly handled.
|
||||
//
|
||||
// Ref: https://github.com/babel/babel/pull/7065#issuecomment-395959112
|
||||
"transform-dotall-regex": "s (dotAll) flag for regular expressions",
|
||||
|
||||
"transform-unicode-regex": {
|
||||
features: [
|
||||
'RegExp "y" and "u" flags / "u" flag, case folding',
|
||||
'RegExp "y" and "u" flags / "u" flag, Unicode code point escapes',
|
||||
'RegExp "y" and "u" flags / "u" flag, non-BMP Unicode characters',
|
||||
'RegExp "y" and "u" flags / "u" flag',
|
||||
],
|
||||
},
|
||||
|
||||
"transform-spread": {
|
||||
features: "spread syntax for iterable objects",
|
||||
},
|
||||
"transform-parameters": {
|
||||
features: [
|
||||
"default function parameters",
|
||||
"rest parameters",
|
||||
"destructuring, parameters / defaults, arrow function",
|
||||
],
|
||||
},
|
||||
"transform-destructuring": {
|
||||
features: ["destructuring, assignment", "destructuring, declarations"],
|
||||
},
|
||||
"transform-block-scoping": {
|
||||
features: ["const", "let"],
|
||||
},
|
||||
"transform-typeof-symbol": {
|
||||
features: ["Symbol / typeof support"],
|
||||
},
|
||||
"transform-new-target": {
|
||||
features: ["new.target"],
|
||||
},
|
||||
"transform-regenerator": {
|
||||
features: ["generators"],
|
||||
},
|
||||
|
||||
"transform-exponentiation-operator": {
|
||||
features: ["exponentiation (**) operator"],
|
||||
},
|
||||
|
||||
"transform-async-to-generator": {
|
||||
features: ["async functions"],
|
||||
},
|
||||
|
||||
"proposal-async-generator-functions": "Asynchronous Iterators",
|
||||
"proposal-object-rest-spread": "object rest/spread properties",
|
||||
"proposal-unicode-property-regex": "RegExp Unicode Property Escapes",
|
||||
|
||||
"proposal-json-strings": "JSON superset",
|
||||
"proposal-optional-catch-binding": "optional catch binding",
|
||||
"transform-named-capturing-groups-regex": "RegExp named capture groups",
|
||||
"transform-member-expression-literals":
|
||||
"Object/array literal extensions / Reserved words as property names",
|
||||
"transform-property-literals":
|
||||
"Object/array literal extensions / Reserved words as property names",
|
||||
"transform-reserved-words": "Miscellaneous / Unreserved words",
|
||||
};
|
||||
8
packages/babel-compat-data/scripts/download-compat-table.sh
Executable file
8
packages/babel-compat-data/scripts/download-compat-table.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
COMPAT_TABLE_COMMIT=4195aca631ad904cb0efeb62a9c2d8c8511706f8
|
||||
rm -rf build/compat-table
|
||||
mkdir -p build
|
||||
git clone --branch=gh-pages --single-branch --shallow-since=2019-11-14 https://github.com/kangax/compat-table.git build/compat-table
|
||||
cd build/compat-table && git checkout -qf $COMPAT_TABLE_COMMIT
|
||||
Reference in New Issue
Block a user