Skip to content

docs: clarify how to set browserslist #1057

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

Merged
merged 1 commit into from
Jun 16, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions website/docs/en/guide/advanced/output-compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ This chapter introduces how to specify which target environment should be suppor

## Syntax downgrade

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`.

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.
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.

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).

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).

## Polyfill

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).
Expand Down
6 changes: 3 additions & 3 deletions website/docs/zh/guide/advanced/output-compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { PackageManagerTabs } from '@theme';

## 语法降级

通过设置 [lib.syntax](/config/lib/syntax),你可以选择 JavaScript 和 CSS 将被降级到的语法。你可以使用 [Browserslist](https://browsersl.ist/) 的查询语法。Rslib 还支持常见的 ECMAScript 版本号,例如 `ES2015`。

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

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

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

## Polyfill

在处理兼容性问题之前,建议了解以下背景知识,以便更好地处理相关问题。请查看有关 [语法降级和 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) 的背景知识。
Expand Down
Loading