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

Use chrome data when android is absent #10790

Merged
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
2 changes: 1 addition & 1 deletion packages/babel-preset-env/package.json
Expand Up @@ -60,7 +60,7 @@
"@babel/plugin-transform-typeof-symbol": "^7.7.4",
"@babel/plugin-transform-unicode-regex": "^7.7.4",
"@babel/types": "^7.7.4",
"browserslist": "^4.6.0",
"browserslist": "^4.8.2",
"core-js-compat": "^3.6.0",
"invariant": "^2.2.2",
"levenary": "^1.1.0",
Expand Down
9 changes: 7 additions & 2 deletions packages/babel-preset-env/src/debug.js
@@ -1,7 +1,12 @@
// @flow
/*eslint quotes: ["error", "double", { "avoidEscape": true }]*/
import semver from "semver";
import { isUnreleasedVersion, prettifyVersion, semverify } from "./utils";
import {
isUnreleasedVersion,
prettifyVersion,
semverify,
getLowestImplementedVersion,
} from "./utils";

import type { Targets } from "./types";

Expand All @@ -19,7 +24,7 @@ export const logPluginOrPolyfill = (
const minVersions = list[item] || {};

const filteredList = Object.keys(targetVersions).reduce((result, env) => {
const minVersion = minVersions[env];
const minVersion = getLowestImplementedVersion(minVersions, env);
const targetVersion = targetVersions[env];

if (!minVersion) {
Expand Down
14 changes: 10 additions & 4 deletions packages/babel-preset-env/src/filter-items.js
@@ -1,6 +1,10 @@
// @flow
import semver from "semver";
import { semverify, isUnreleasedVersion } from "./utils";
import {
semverify,
isUnreleasedVersion,
getLowestImplementedVersion,
} from "./utils";

import type { Targets } from "./types";

Expand All @@ -15,12 +19,14 @@ export function isPluginRequired(
}

const isRequiredForEnvironments = targetEnvironments.filter(environment => {
const lowestImplementedVersion = getLowestImplementedVersion(
plugin,
environment,
);
// Feature is not implemented in that environment
if (!plugin[environment]) {
if (!lowestImplementedVersion) {
return true;
}

const lowestImplementedVersion = plugin[environment];
const lowestTargetedVersion = supportedEnvironments[environment];

// If targets has unreleased value as a lowest version, then don't require a plugin.
Expand Down
14 changes: 13 additions & 1 deletion packages/babel-preset-env/src/utils.js
Expand Up @@ -7,7 +7,7 @@ import semver from "semver";
import { addSideEffect } from "@babel/helper-module-imports";
import unreleasedLabels from "../data/unreleased-labels";
import { semverMin } from "./targets-parser";
import type { Targets } from "./types";
import type { Target, Targets } from "./types";

export const has = Object.hasOwnProperty.call.bind(Object.hasOwnProperty);

Expand Down Expand Up @@ -105,6 +105,18 @@ export function getLowestUnreleased(a: string, b: string, env: string): string {
return semverMin(a, b);
}

export function getLowestImplementedVersion(
plugin: Targets,
environment: Target,
): string {
const result = plugin[environment];
// When Android support data is absent, use Chrome data as fallback
if (!result && environment === "android") {
return plugin.chrome;
}
return result;
}

export function filterStageFromList(
list: { [feature: string]: Targets },
stageList: { [feature: string]: boolean },
Expand Down
@@ -0,0 +1 @@
import "core-js";
@@ -0,0 +1,17 @@
{
"validateLogs": true,
"ignoreOutput": true,
"presets": [
[
"env",
{
"debug": true,
"targets": {
"browsers": [
"android 3"
]
}
}
]
]
}
@@ -0,0 +1,46 @@
@babel/preset-env: `DEBUG` option

Using targets:
{
"android": "3"
}

Using modules transform: auto

Using plugins:
transform-template-literals { "android":"3" }
transform-literals { "android":"3" }
transform-function-name { "android":"3" }
transform-arrow-functions { "android":"3" }
transform-block-scoped-functions { "android":"3" }
transform-classes { "android":"3" }
transform-object-super { "android":"3" }
transform-shorthand-properties { "android":"3" }
transform-duplicate-keys { "android":"3" }
transform-computed-properties { "android":"3" }
transform-for-of { "android":"3" }
transform-sticky-regex { "android":"3" }
transform-dotall-regex { "android":"3" }
transform-unicode-regex { "android":"3" }
transform-spread { "android":"3" }
transform-parameters { "android":"3" }
transform-destructuring { "android":"3" }
transform-block-scoping { "android":"3" }
transform-typeof-symbol { "android":"3" }
transform-new-target { "android":"3" }
transform-regenerator { "android":"3" }
transform-exponentiation-operator { "android":"3" }
transform-async-to-generator { "android":"3" }
proposal-async-generator-functions { "android":"3" }
proposal-object-rest-spread { "android":"3" }
proposal-unicode-property-regex { "android":"3" }
proposal-json-strings { "android":"3" }
proposal-optional-catch-binding { "android":"3" }
transform-named-capturing-groups-regex { "android":"3" }
transform-member-expression-literals { "android":"3" }
transform-property-literals { "android":"3" }
transform-reserved-words { "android":"3" }
transform-modules-commonjs { "android":"3" }
proposal-dynamic-import { "android":"3" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
@@ -0,0 +1 @@
import "core-js";
@@ -0,0 +1,19 @@
{
"validateLogs": true,
"ignoreOutput": true,
"presets": [
[
"env",
{
"debug": true,
"targets": {
"browsers": [
"defaults",
"not ie 11",
"not ie_mob 11"
]
}
}
]
]
}
@@ -0,0 +1,50 @@
@babel/preset-env: `DEBUG` option

Using targets:
{
"android": "77",
"chrome": "77",
"edge": "17",
"firefox": "68",
"ios": "12.2",
"opera": "63",
"safari": "5.1",
"samsung": "9.2"
}

Using modules transform: auto

Using plugins:
transform-template-literals { "ios":"12.2", "safari":"5.1" }
transform-literals { "safari":"5.1" }
transform-function-name { "edge":"17", "safari":"5.1" }
transform-arrow-functions { "safari":"5.1" }
transform-block-scoped-functions { "safari":"5.1" }
transform-classes { "safari":"5.1" }
transform-object-super { "safari":"5.1" }
transform-shorthand-properties { "safari":"5.1" }
transform-duplicate-keys { "safari":"5.1" }
transform-computed-properties { "safari":"5.1" }
transform-for-of { "safari":"5.1" }
transform-sticky-regex { "safari":"5.1" }
transform-dotall-regex { "edge":"17", "firefox":"68", "safari":"5.1" }
transform-unicode-regex { "safari":"5.1" }
transform-spread { "safari":"5.1" }
transform-parameters { "edge":"17", "safari":"5.1" }
transform-destructuring { "safari":"5.1" }
transform-block-scoping { "safari":"5.1" }
transform-typeof-symbol { "safari":"5.1" }
transform-new-target { "safari":"5.1" }
transform-regenerator { "safari":"5.1" }
transform-exponentiation-operator { "safari":"5.1" }
transform-async-to-generator { "safari":"5.1" }
proposal-async-generator-functions { "edge":"17", "safari":"5.1" }
proposal-object-rest-spread { "edge":"17", "safari":"5.1" }
proposal-unicode-property-regex { "edge":"17", "firefox":"68", "safari":"5.1" }
proposal-json-strings { "edge":"17", "safari":"5.1" }
proposal-optional-catch-binding { "edge":"17", "safari":"5.1" }
transform-named-capturing-groups-regex { "edge":"17", "firefox":"68", "safari":"5.1" }
transform-modules-commonjs { "android":"77", "chrome":"77", "edge":"17", "firefox":"68", "ios":"12.2", "opera":"63", "safari":"5.1", "samsung":"9.2" }
proposal-dynamic-import { "android":"77", "chrome":"77", "edge":"17", "firefox":"68", "ios":"12.2", "opera":"63", "safari":"5.1", "samsung":"9.2" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
@@ -0,0 +1 @@
import "core-js";
@@ -0,0 +1,15 @@
{
"validateLogs": true,
"ignoreOutput": true,
"presets": [
[
"env",
{
"debug": true,
"targets": {
"browsers": "defaults"
}
}
]
]
}
@@ -0,0 +1,51 @@
@babel/preset-env: `DEBUG` option

Using targets:
{
"android": "77",
"chrome": "77",
"edge": "17",
"firefox": "68",
"ie": "11",
"ios": "12.2",
"opera": "63",
"safari": "5.1",
"samsung": "9.2"
}

Using modules transform: auto

Using plugins:
transform-template-literals { "ie":"11", "ios":"12.2", "safari":"5.1" }
transform-literals { "ie":"11", "safari":"5.1" }
transform-function-name { "edge":"17", "ie":"11", "safari":"5.1" }
transform-arrow-functions { "ie":"11", "safari":"5.1" }
transform-block-scoped-functions { "safari":"5.1" }
transform-classes { "ie":"11", "safari":"5.1" }
transform-object-super { "ie":"11", "safari":"5.1" }
transform-shorthand-properties { "ie":"11", "safari":"5.1" }
transform-duplicate-keys { "ie":"11", "safari":"5.1" }
transform-computed-properties { "ie":"11", "safari":"5.1" }
transform-for-of { "ie":"11", "safari":"5.1" }
transform-sticky-regex { "ie":"11", "safari":"5.1" }
transform-dotall-regex { "edge":"17", "firefox":"68", "ie":"11", "safari":"5.1" }
transform-unicode-regex { "ie":"11", "safari":"5.1" }
transform-spread { "ie":"11", "safari":"5.1" }
transform-parameters { "edge":"17", "ie":"11", "safari":"5.1" }
transform-destructuring { "ie":"11", "safari":"5.1" }
transform-block-scoping { "ie":"11", "safari":"5.1" }
transform-typeof-symbol { "ie":"11", "safari":"5.1" }
transform-new-target { "ie":"11", "safari":"5.1" }
transform-regenerator { "ie":"11", "safari":"5.1" }
transform-exponentiation-operator { "ie":"11", "safari":"5.1" }
transform-async-to-generator { "ie":"11", "safari":"5.1" }
proposal-async-generator-functions { "edge":"17", "ie":"11", "safari":"5.1" }
proposal-object-rest-spread { "edge":"17", "ie":"11", "safari":"5.1" }
proposal-unicode-property-regex { "edge":"17", "firefox":"68", "ie":"11", "safari":"5.1" }
proposal-json-strings { "edge":"17", "ie":"11", "safari":"5.1" }
proposal-optional-catch-binding { "edge":"17", "ie":"11", "safari":"5.1" }
transform-named-capturing-groups-regex { "edge":"17", "firefox":"68", "ie":"11", "safari":"5.1" }
transform-modules-commonjs { "android":"77", "chrome":"77", "edge":"17", "firefox":"68", "ie":"11", "ios":"12.2", "opera":"63", "safari":"5.1", "samsung":"9.2" }
proposal-dynamic-import { "android":"77", "chrome":"77", "edge":"17", "firefox":"68", "ie":"11", "ios":"12.2", "opera":"63", "safari":"5.1", "samsung":"9.2" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
@@ -0,0 +1 @@
import "core-js";
@@ -0,0 +1,19 @@
{
"validateLogs": true,
"ignoreOutput": true,
"presets": [
[
"env",
{
"debug": true,
"targets": {
"browsers": [
"last 2 versions",
"not ie <= 11",
"not ie_mob <= 11"
]
}
}
]
]
}
@@ -0,0 +1,31 @@
@babel/preset-env: `DEBUG` option

Using targets:
{
"android": "77",
"chrome": "77",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently the chrome 49 usage just drops to 0.5% and therefore excluded from browserslists defaults > 0.5% now.

"edge": "17",
"firefox": "70",
"ios": "13",
"opera": "63",
"safari": "12.1",
"samsung": "9.2"
}

Using modules transform: auto

Using plugins:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugins listed here is generated from a sort-of modern browserslist configuration. It can help us prioritize bug fixes in the current transforms. because these plugins are expected to be used for a longer time than other standard transforms.

transform-template-literals { "safari":"12.1" }
transform-function-name { "edge":"17" }
transform-dotall-regex { "edge":"17", "firefox":"70" }
transform-parameters { "edge":"17" }
proposal-async-generator-functions { "edge":"17" }
proposal-object-rest-spread { "edge":"17" }
proposal-unicode-property-regex { "edge":"17", "firefox":"70" }
proposal-json-strings { "edge":"17" }
proposal-optional-catch-binding { "edge":"17" }
transform-named-capturing-groups-regex { "edge":"17", "firefox":"70" }
transform-modules-commonjs { "android":"77", "chrome":"77", "edge":"17", "firefox":"70", "ios":"13", "opera":"63", "safari":"12.1", "samsung":"9.2" }
proposal-dynamic-import { "android":"77", "chrome":"77", "edge":"17", "firefox":"70", "ios":"13", "opera":"63", "safari":"12.1", "samsung":"9.2" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Expand Up @@ -5,7 +5,7 @@
{
"targets": {
"node": "current",
"browsers": ["defaults", "not ie <= 10"]
"browsers": ["defaults", "not ie <= 10", "not ie_mob <= 10"]
}
}
]
Expand Down