Include preset modules (#11083)
* Prepare preset-env and compat-data for preset-modules
* Add transform-edge-default-parameters from preset-modules
* AUtomatically generate data from compat-table
* Add compat data for other plugins
* Updates after rebase
* Add more bugfixes to preset-env
* Update tests
* Add bugfix/transform-safari-for-shadowing
* Fix build script
* bugfix/transform-safari-block-shadowing
* Fix flow
* Include changes from 7127330f02
* Fix check-compat-data
This commit is contained in:
77
packages/babel-compat-data/scripts/build-bugfixes-targets.js
Normal file
77
packages/babel-compat-data/scripts/build-bugfixes-targets.js
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
// NOTE: This script must be run _after_ build-data.js
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const {
|
||||
getLowestImplementedVersion,
|
||||
environments,
|
||||
addOperaAndElectron,
|
||||
writeFile,
|
||||
} = require("./utils-build-data");
|
||||
|
||||
const data = require("./data/plugin-bugfixes");
|
||||
const pluginFeatures = require("./data/plugin-features");
|
||||
|
||||
const generatedTargets = {};
|
||||
const overlappingPlugins = {};
|
||||
|
||||
const allReplacedFeatures = {};
|
||||
|
||||
const has = Function.call.bind(Object.hasOwnProperty);
|
||||
|
||||
for (const [plugin, { replaces, features }] of Object.entries(data)) {
|
||||
if (!has(overlappingPlugins, replaces)) {
|
||||
overlappingPlugins[replaces] = [];
|
||||
generatedTargets[replaces] = {};
|
||||
allReplacedFeatures[replaces] = [];
|
||||
}
|
||||
generatedTargets[plugin] = {};
|
||||
|
||||
allReplacedFeatures[replaces].push(...features);
|
||||
|
||||
overlappingPlugins[replaces].push(plugin);
|
||||
|
||||
for (const env of environments) {
|
||||
const supportedWithBugfix = getLowestImplementedVersion({ features }, env);
|
||||
if (supportedWithBugfix) {
|
||||
generatedTargets[plugin][env] = supportedWithBugfix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const [replaced, features] of Object.entries(allReplacedFeatures)) {
|
||||
let replacedFeatures = pluginFeatures[replaced];
|
||||
if (!Array.isArray(replacedFeatures)) {
|
||||
replacedFeatures = replacedFeatures.features;
|
||||
}
|
||||
|
||||
for (const env of environments) {
|
||||
const stillNotSupported = getLowestImplementedVersion(
|
||||
{ features: replacedFeatures },
|
||||
env,
|
||||
name => features.some(feat => name.includes(feat))
|
||||
);
|
||||
|
||||
if (stillNotSupported) {
|
||||
generatedTargets[replaced][env] = stillNotSupported;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const plugin of Object.values(generatedTargets)) {
|
||||
addOperaAndElectron(plugin);
|
||||
}
|
||||
|
||||
for (const [filename, data] of [
|
||||
["plugin-bugfixes", generatedTargets],
|
||||
["overlapping-plugins", overlappingPlugins],
|
||||
]) {
|
||||
const dataPath = path.join(__dirname, `../data/${filename}.json`);
|
||||
|
||||
if (!writeFile(data, dataPath, filename)) {
|
||||
process.exitCode = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user