ブラウザ対応
Docusaurus allows sites to define the list of supported browsers through a browserslist configuration.
目的
Webサイトでは、後方互換性とバンドルサイズのバランスを取る必要があります。古いブラウザは最新のAPIや構文に対応していないため、同じ機能を実装するためにはより多くのコードが必要になります。
For example, you may use the optional chaining syntax:
const value = obj?.prop?.val;
しかしこれは残念ながら、2020年以降にリリースされたブラウザのバージョンでしか認識されません。それ以前のブラウザバージョンと互換性を持たせるため、本番用のサイトを構築する際には、私たちのJSローダーがこのようなコードを次のようなより回りくどい構文にトランスパイル(変換)します。
var _obj, _obj$prop;
const value =
(_obj = obj) === null || _obj === void 0
? void 0
: (_obj$prop = _obj.prop) === null || _obj$prop === void 0
? void 0
: _obj$prop.val;
しかし、この場合、29文字の行が168文字と6倍になるため、サイトのロード時間が長くなり、他のすべてのユーザーに不利益をもたらすことになります!(実際には、使用される名前が短縮されるため、よりマシにはなります)トレードオフとして、JSローダーは、ブラウザリストに定義されているすべてのブラウザのバージョンでサポートされている程度までにしか構文を変換しません。
The browser list by default is provided through the package.json file as a root browserslist field.
古いブラウザでは、コンパイルされた出力にサポートされていない(新しすぎる)JS構文が使用されるため、Reactの初期化に失敗し、HTML/CSSのみでJSがない静的なウェブサイトになってしまいます。
既定値
Websites initialized with the default classic template has the following in package.json:
{
"name": "docusaurus",
// ...
"browserslist": ["baseline widely available"]
// ...
}
Explained in natural language, the browsers supported are the versions of the core browsers (Chrome, Edge, Firefox and Safari, on desktop and mobile) that support all the Baseline Widely available web platform features, i.e. features that have been available in all core browsers for at least 30 months.
The same browser list is used in development and production, so that your site behaves the same with docusaurus start and docusaurus build.
It remains possible to use a different browser list for each environment with an object keyed by environment (production, development). Refer to the browserslist configuration documentation.
You can "evaluate" any config with the browserslist CLI to obtain the actual list:
npx browserslist
The output is all browsers supported. Below is the output in September 2026:
and_chr 151
and_ff 153
chrome 151
chrome 150
...
chrome 123
edge 151
edge 150
...
edge 123
firefox 154
firefox 153
...
firefox 124
ios_saf 26.6
ios_saf 26.5
...
ios_saf 17.4
safari 26.6
safari 26.5
...
safari 17.4
もっと読む
You may wish to visit the browserslist documentation for more specifications, especially the accepted query values and best practices.