@ackee/browserslist-config 中文文档教程

发布于 3年前 浏览 18 项目主页 更新于 3年前

@ackee/browserslist-config

我们在 Akcee 中的项目的默认浏览器列表 - prod env 的浏览器列表

我们的 PM 和我们的客户可以在此处找到更易读的版本。

Usage

yarn add @ackee/browserslist-config -D

将此添加到您的 package.json

    "browserslist": [
        "extends @ackee/browserslist-config"
    ]

Browserslist in create-react-app

Usage

  1. 确保至少安装了 @ackee/react-scripts@1.1.1 版本:

    yarn add @ackee/react-scripts@1.1.1 -D
    
  2. 添加到 package.json< /code>:

    "browserslist": [
        "extends @ackee/browserslist-config"
    ]
    
  3. 在项目的根目录中导入 core-js 以进行正确的 polyfilling: <代码>sh 导入“核心js”;

Recommendations

  1. 由于节点模块通常对最终包大小的影响最大,因此仔细选择这些包至关重要:

    要在项目中利用浏览器列表的功能,选择转换为现代(非- ES5 JavaScript) 尽可能多。

  2. 通过添加 eslint-plugin- 来检查代码的浏览器兼容性compat

Structure

Debugging

@babel/preset-env 可用 调试选项。 您可以将其设置为:

对于仅使用 Chrome 81 的浏览器列表,示例输出可能如下所示:

@babel/preset-env: `DEBUG` option

Using targets:
{
    "chrome": "81"
}

Using modules transform: false

Using plugins:
syntax-nullish-coalescing-operator { "chrome":"81" }
syntax-optional-chaining { "chrome":"81" }
syntax-json-strings { "chrome":"81" }
syntax-optional-catch-binding { "chrome":"81" }
syntax-async-generators { "chrome":"81" }
syntax-object-rest-spread { "chrome":"81" }
syntax-dynamic-import { "chrome":"81" }
syntax-top-level-await { "chrome":"81" }

Using polyfills with `entry` option:

@ackee/browserslist-config

A default browsers list for our projects in Akcee - list of browsers for prod env.

More readble version for our PMs and our clients can found here.

Usage

yarn add @ackee/browserslist-config -D

Add this to your package.json:

    "browserslist": [
        "extends @ackee/browserslist-config"
    ]

Browserslist in create-react-app

Usage

  1. Make sure to have installed at least @ackee/react-scripts@1.1.1 version:

    yarn add @ackee/react-scripts@1.1.1 -D
    
  2. Add to package.json:

    "browserslist": [
        "extends @ackee/browserslist-config"
    ]
    
  3. Import core-js in root of your project for correct polyfilling: sh import 'core-js';

Recommendations

  1. Since node modules often have the largest impact on the final bundle size, it's crucial to choose those packages carefully:

    To leverage the power of browserslist on your project, it's important to choose packages transpiled to modern (non-ES5 JavaScript) as much as possible.

  2. Lint the browser compatibility of your code by adding eslint-plugin-compat

Structure

Debugging

@babel/preset-env has available debug option. You can set it in:

An example output could look like this for browserslist only with Chrome 81:

@babel/preset-env: `DEBUG` option

Using targets:
{
    "chrome": "81"
}

Using modules transform: false

Using plugins:
syntax-nullish-coalescing-operator { "chrome":"81" }
syntax-optional-chaining { "chrome":"81" }
syntax-json-strings { "chrome":"81" }
syntax-optional-catch-binding { "chrome":"81" }
syntax-async-generators { "chrome":"81" }
syntax-object-rest-spread { "chrome":"81" }
syntax-dynamic-import { "chrome":"81" }
syntax-top-level-await { "chrome":"81" }

Using polyfills with `entry` option:
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文