Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lodash from babel-compat-data #13024

Merged
merged 2 commits into from Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/babel-compat-data/package.json
Expand Up @@ -31,7 +31,6 @@
"devDependencies": {
"@mdn/browser-compat-data": "^3.1.1",
"core-js-compat": "^3.9.0",
"electron-to-chromium": "1.3.672",
"lodash": "^4.17.19"
"electron-to-chromium": "1.3.672"
}
}
25 changes: 14 additions & 11 deletions packages/babel-compat-data/scripts/utils-build-data.js
@@ -1,9 +1,6 @@
"use strict";

const fs = require("fs");
const flatMap = require("lodash/flatMap");
const mapValues = require("lodash/mapValues");
const findLastIndex = require("lodash/findLastIndex");
const { addElectronSupportFromChromium } = require("./chromium-to-electron");

const envs = require("../build/compat-table/environments");
Expand Down Expand Up @@ -35,8 +32,8 @@ exports.environments = [
"samsung",
];

const compatibilityTests = flatMap(compatSources, data =>
flatMap(data.tests, test => {
const compatibilityTests = compatSources.flatMap(data =>
data.tests.flatMap(test => {
if (!test.subtests) return test;

return test.subtests.map(subtest =>
Expand All @@ -63,13 +60,19 @@ exports.getLowestImplementedVersion = (
});

const envTests = tests.map(({ res }) => {
const lastNotImplemented = findLastIndex(
envsVersions[env],
const versions = envsVersions[env];
let i = versions.length - 1;

// Find the last not-implemented version
for (; i >= 0; i--) {
const { id } = versions[i];
// Babel assumes strict mode
({ id }) => !(res[id] === true || res[id] === "strict")
);
if (res[id] !== true && res[id] !== "strict") {
break;
}
}

return envsVersions[env][lastNotImplemented + 1];
return envsVersions[env][i + 1];
});

if (envTests.length === 0 || envTests.some(t => !t)) return null;
Expand All @@ -85,7 +88,7 @@ exports.getLowestImplementedVersion = (
};

exports.generateData = (environments, features) => {
return mapValues(features, options => {
return Object.values(features).map(options => {
if (!options.features) {
options = {
features: [options],
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Expand Up @@ -146,7 +146,6 @@ __metadata:
"@mdn/browser-compat-data": ^3.1.1
core-js-compat: ^3.9.0
electron-to-chromium: 1.3.672
lodash: ^4.17.19
languageName: unknown
linkType: soft

Expand Down