Skip to content

Commit c919ea7

Browse files
authored
docs: clarify how to set browserslist (#1057)
1 parent 34fe99b commit c919ea7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

website/docs/en/guide/advanced/output-compatibility.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ This chapter introduces how to specify which target environment should be suppor
77

88
## Syntax downgrade
99

10-
By setting [lib.syntax](/config/lib/syntax), you can choose the syntax to which JavaScript and CSS will be downgraded. You can use the query syntax from [Browserslist](https://browsersl.ist/). Rslib also supports common ECMAScript version numbers, such as `ES2015`.
11-
12-
Rslib also supports using a [.browserslistrc](https://github.com/browserslist/browserslist#config-file) file to specify settings. Note that [lib.syntax](/config/lib/syntax) takes precedence over `.browserslistrc`. If both are present, `lib.syntax` will be used.
10+
In Rslib, you can configure the syntax to which JavaScript and CSS will be downgraded by setting [lib.syntax](/config/lib/syntax). This configuration supports setting the ECMAScript version directly, such as `es2015`, `es2022`, etc., and also supports setting the query syntax of [Browserslist](https://browsersl.ist/), such as `last 2 versions`, `> 1%`, `node >= 16`, `chrome >= 80`, etc.
1311

1412
By default, the syntax is set to `ESNext`, which will only supports only the latest version of mainstream browsers (Chrome / Firefox / Edge / macOS Safari / iOS Safari) or Node.js according to [output.target](/config/rsbuild/output#outputtarget).
1513

14+
It should be noted that Rslib does not read the Browserslist related configuration files (such as `.browserslistrc` or the `browserslist` field in `package.json`). You can override by setting [output.overrideBrowserslist](/config/rsbuild/output#outputoverridebrowserslist) which has a higher priority than [lib.syntax](/config/lib/syntax).
15+
1616
## Polyfill
1717

1818
Before dealing with compatibility issues, it is recommended that you understand the following background knowledge to better handle related issues. Check out the background knowledge on [syntax transpilation and API polyfill](https://rsbuild.rs/guide/advanced/browser-compatibility#syntax-downgrade-and-api-downgrade).

website/docs/zh/guide/advanced/output-compatibility.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { PackageManagerTabs } from '@theme';
77

88
## 语法降级
99

10-
通过设置 [lib.syntax](/config/lib/syntax),你可以选择 JavaScript 和 CSS 将被降级到的语法。你可以使用 [Browserslist](https://browsersl.ist/) 的查询语法。Rslib 还支持常见的 ECMAScript 版本号,例如 `ES2015`
11-
12-
Rslib 还支持使用 [.browserslistrc](https://github.com/browserslist/browserslist#config-file) 文件来设置。需要注意的是,[lib.syntax](/config/lib/syntax) 优先于 `.browserslistrc`。如果两者都存在,将使用 `lib.syntax`
10+
在 Rslib 中,你可以通过设置 [lib.syntax](/config/lib/syntax) 来选择 JavaScript 和 CSS 将被降级到的语法。该配置支持直接设置 ECMAScript 版本,例如 `es2015``es2022` 等,也支持设置 [Browserslist](https://browsersl.ist/) 的查询语法,例如 `last 2 versions``> 1%``node >= 16``chrome >= 80` 等。
1311

1412
默认情况下,syntax 被设置为 `ESNext`,这代表将仅支持主流浏览器(Chrome / Firefox / Edge / macOS Safari / iOS Safari)或 Node.js 的最新版本,具体取决于 [output.target](/config/rsbuild/output#outputtarget)
1513

14+
需要注意的是,Rslib 不会读取 Browserslist 的相关配置文件(例如 `.browserslistrc``package.json` 中的 `browserslist` 字段)。你可以通过设置 [output.overrideBrowserslist](/config/rsbuild/output#outputoverridebrowserslist) 进行覆盖,该配置比 [lib.syntax](/config/lib/syntax) 拥有更高的优先级。
15+
1616
## Polyfill
1717

1818
在处理兼容性问题之前,建议了解以下背景知识,以便更好地处理相关问题。请查看有关 [语法降级和 API 降级](https://rsbuild.rs/zh/guide/advanced/browser-compatibility#%E8%AF%AD%E6%B3%95%E9%99%8D%E7%BA%A7%E5%92%8C-api-%E9%99%8D%E7%BA%A7) 的背景知识。

0 commit comments

Comments
 (0)