Skip to content

Warn about unused browsers from browserslist in preset-env #8545

Description

@ylemkimon

Feature Request

Is your feature request related to a problem? Please describe.
@babel/preset-env only uses Android, Chrome, Edge, Firefox, IE, iOS, Safari, Node versions for detecting which transforms to include:

const browserNameMap = {
android: "android",
chrome: "chrome",
and_chr: "chrome",
edge: "edge",
firefox: "firefox",
ie: "ie",
ios_saf: "ios",
safari: "safari",
node: "node",
};

and silently ignores other browsers:

const normalizedBrowserName = browserNameMap[browserName];
if (!normalizedBrowserName) {
return all;
}

However, there are local-popular or manufacturer-specific browsers such as Opera Mini, UC browser, QQ browser, Baidu browser, and Samsung Internet. Please see browserslist/browserslist#250 for their importance.

In Browserslist default, fortunately, IE 11, Chrome 49 (usage 0.69%) and Android 4.x (4.4 usage 0.58%, 4.4.4 isn't strictly last 2 versions) acts as a stopgap preventing from excluding transform needed for old browsers. However, if user excludes them, they become dead, or their usage drops, preset-env will recognize as if it targets very modern browsers. Also, user may explicitly target them, using Browserslist config.

Describe the solution you'd like
Warn users about unused (unsupported, those preset-env doesn't have data) browsers like:

Following browser(s) were selected by Browserslist,
but @babel/preset-env doesn't know about their features.
Please add plugins and built-ins manually, if needed:
{
  "baidu": "7.12",
  "samsung": "7",
}

at least on DEBUG mode.

Then, the user can add necessary plugins and built-ins manually, or update Browserslist to exclude them.

Describe alternatives you've considered
For Chromium-based browsers (UC, QQ, Baidu, Samsung), we can use a mapping to Chromium versions, like electron-to-chromium. I've opened an issue at browserslist/browserslist#290. I'll open an issue here, if it gets rejected. #8552.

Teachability, Documentation, Adoption, Migration Strategy
See above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions