sourav-das/stem-separator
3
1# [`baseline-browser-mapping`](https://github.com/web-platform-dx/web-features/packages/baseline-browser-mapping)2 3By the [W3C WebDX Community Group](https://www.w3.org/community/webdx/) and contributors.4 5`baseline-browser-mapping` provides:6 7- An `Array` of browsers compatible with Baseline Widely available and Baseline year feature sets via the [`getCompatibleVersions()` function](#get-baseline-widely-available-browser-versions-or-baseline-year-browser-versions).8- An `Array`, `Object` or `CSV` as a string describing the Baseline feature set support of all browser versions included in the module's data set via the [`getAllVersions()` function](#get-data-for-all-browser-versions).9 10You can use `baseline-browser-mapping` to help you determine minimum browser version support for your chosen Baseline feature set; or to analyse the level of support for different Baseline feature sets in your site's traffic by joining the data with your analytics data.11 12## Install for local development13 14To install the package, run:15 16`npm install --save-dev baseline-browser-mapping`17 18The minimum supported NodeJS version for `baseline-browser-mapping` is v8 in alignment with `browserslist`. For NodeJS versions earlier than v13.2, the [`require('baseline-browser-mapping')`](https://nodejs.org/api/modules.html#requireid) syntax should be used to import the module.19 20## Keeping `baseline-browser-mapping` up to date21 22`baseline-browser-mapping` depends on `web-features` and `@mdn/browser-compat-data` for core browser version selection, but the data is pre-packaged and minified. This package checks for updates to those modules and the supported [downstream browsers](#downstream-browsers) on a daily basis and is updated frequently.23 24If you are only using this module to generate minimum browser versions for Baseline Widely available or Baseline year feature sets, you don't need to update this module frequently, as the backward looking data is reasonably stable.25 26However, if you are targeting Newly available, using the [`getAllVersions()`](#get-data-for-all-browser-versions) function or heavily relying on the data for downstream browsers, you should update this module more frequently. If you target a feature cut off date within the last two months and your installed version of `baseline-browser-mapping` has data that is more than 2 months old, you will receive a console warning advising you to update to the latest version when you call `getCompatibleVersions()` or `getAllVersions()`.27 28If you want to suppress the console warnings mentioned above you can use the `suppressWarnings: true` option in the configuration object passed to `getCompatibleVersions()` or `getAllVersions()`. Alternatively, you can use the `BASELINE_BROWSER_MAPPING_IGNORE_OLD_DATA=true` environment variable when running your build process. This module also respects the `BROWSERSLIST_IGNORE_OLD_DATA=true` environment variable. Environment variables can also be provided in a `.env` file from Node 20 onwards; however, this module does not load .env files automatically to avoid conflicts with other libraries with different requirements. You will need to use `process.loadEnvFile()` or a library like `dotenv` to load .env files before `baseline-browser-mapping` is called.29 30If you're building a tool that uses this module, consider suppressing the warnings but building a process into your tool that automatically updates this module. See, for example, [`browserslist`](https://github.com/browserslist/browserslist/blob/main/node.js#L471) and its [`update-browserslist-db`](https://github.com/browserslist/update-db) package.31 32If you're implementing `baseline-browser-mapping` directly, you should add a script to your `package.json` to update `baseline-browser-mapping` and use it as part of your build process to ensure your data is as up to date as possible. For example, if you are using NPM for package management:33 34```javascript35"scripts": [36 "refresh-baseline-browser-mapping": "npm i baseline-browser-mapping@latest -D"37]38```39 40If you want to ensure [reproducible builds](https://www.wikiwand.com/en/articles/Reproducible_builds), we strongly recommend using the `widelyAvailableOnDate` option to fix the Widely available date on a per build basis to ensure dependent tools provide the same output and you do not produce data staleness warnings. If you are using [`browserslist`](https://github.com/browserslist/browserslist) to target Baseline Widely available, consider automatically updating your `browserslist` configuration in `package.json` or `.browserslistrc` to `baseline widely available on {YYYY-MM-DD}` as part of your build process to ensure the same or sufficiently similar list of minimum browsers is reproduced for historical builds.41 42## Importing `baseline-browser-mapping`43 44This module exposes two functions: `getCompatibleVersions()` and `getAllVersions()`, both which can be imported directly from `baseline-browser-mapping`:45 46```javascript47import {48 getCompatibleVersions,49 getAllVersions,50} from "baseline-browser-mapping";51```52 53If you want to load the script and data directly in a web page without hosting it yourself, consider using a CDN:54 55```html56<script type="module">57 import {58 getCompatibleVersions,59 getAllVersions,60 } from "https://cdn.jsdelivr.net/npm/baseline-browser-mapping";61</script>62```63 64## Get Baseline Widely available browser versions or Baseline year browser versions65 66To get the current list of minimum browser versions compatible with Baseline Widely available features from the core browser set, call the `getCompatibleVersions()` function:67 68```javascript69getCompatibleVersions();70```71 72Executed on 7th March 2025, the above code returns the following browser versions:73 74```javascript75[76 { browser: "chrome", version: "105", release_date: "2022-09-02" },77 {78 browser: "chrome_android",79 version: "105",80 release_date: "2022-09-02",81 },82 { browser: "edge", version: "105", release_date: "2022-09-02" },83 { browser: "firefox", version: "104", release_date: "2022-08-23" },84 {85 browser: "firefox_android",86 version: "104",87 release_date: "2022-08-23",88 },89 { browser: "safari", version: "15.6", release_date: "2022-09-02" },90 {91 browser: "safari_ios",92 version: "15.6",93 release_date: "2022-09-02",94 },95];96```97 98> [!NOTE]99> The minimum versions of each browser are not necessarily the final release before the Widely available cutoff date of `TODAY - 30 MONTHS`. Some earlier versions will have supported the full Widely available feature set.100 101### `getCompatibleVersions()` configuration options102 103`getCompatibleVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:104 105```javascript106{107 targetYear: undefined,108 widelyAvailableOnDate: undefined,109 includeDownstreamBrowsers: false,110 listAllCompatibleVersions: false,111 suppressWarnings: false112}113```114 115#### `targetYear`116 117The `targetYear` option returns the minimum browser versions compatible with all **Baseline Newly available** features at the end of the specified calendar year. For example, calling:118 119```javascript120getCompatibleVersions({121 targetYear: 2020,122});123```124 125Returns the following versions:126 127```javascript128[129 { browser: "chrome", version: "87", release_date: "2020-11-19" },130 {131 browser: "chrome_android",132 version: "87",133 release_date: "2020-11-19",134 },135 { browser: "edge", version: "87", release_date: "2020-11-19" },136 { browser: "firefox", version: "83", release_date: "2020-11-17" },137 {138 browser: "firefox_android",139 version: "83",140 release_date: "2020-11-17",141 },142 { browser: "safari", version: "14", release_date: "2020-09-16" },143 { browser: "safari_ios", version: "14", release_date: "2020-09-16" },144];145```146 147> [!NOTE]148> The minimum version of each browser is not necessarily the final version released in that calendar year. In the above example, Firefox 84 was the final version released in 2020; however Firefox 83 supported all of the features that were interoperable at the end of 2020.149> [!WARNING]150> You cannot use `targetYear` and `widelyAavailableDate` together. Please only use one of these options at a time.151 152#### `widelyAvailableOnDate`153 154The `widelyAvailableOnDate` option returns the minimum versions compatible with Baseline Widely available on a specified date in the format `YYYY-MM-DD`:155 156```javascript157getCompatibleVersions({158 widelyAvailableOnDate: `2023-04-05`,159});160```161 162> [!TIP]163> This option is useful if you provide a versioned library that targets Baseline Widely available on each version's release date and you need to provide a statement on minimum supported browser versions in your documentation.164 165#### `includeDownstreamBrowsers`166 167Setting `includeDownstreamBrowsers` to `true` will include browsers outside of the Baseline core browser set where it is possible to map those browsers to an upstream Chromium or Gecko version:168 169```javascript170getCompatibleVersions({171 includeDownstreamBrowsers: true,172});173```174 175For more information on downstream browsers, see [the section on downstream browsers](#downstream-browsers) below.176 177#### `includeKaiOS`178 179KaiOS is an operating system and app framework based on the Gecko engine from Firefox. KaiOS is based on the Gecko engine and feature support can be derived from the upstream Gecko version that each KaiOS version implements. However KaiOS requires other considerations beyond feature compatibility to ensure a good user experience as it runs on device types that do not have either mouse and keyboard or touch screen input in the way that all the other browsers supported by this module do.180 181```javascript182getCompatibleVersions({183 includeDownstreamBrowsers: true,184 includeKaiOS: true,185});186```187 188> [!NOTE]189> Including KaiOS requires you to include all downstream browsers using the `includeDownstreamBrowsers` option.190 191#### `listAllCompatibleVersions`192 193Setting `listAllCompatibleVersions` to true will include the minimum versions of each compatible browser, and all the subsequent versions:194 195```javascript196getCompatibleVersions({197 listAllCompatibleVersions: true,198});199```200 201#### `suppressWarnings`202 203Setting `suppressWarnings` to `true` will suppress the console warning about old data:204 205```javascript206getCompatibleVersions({207 suppressWarnings: true,208});209```210 211## Get data for all browser versions212 213You may want to obtain data on all the browser versions available in this module for use in an analytics solution or dashboard. To get details of each browser version's level of Baseline support, call the `getAllVersions()` function:214 215```javascript216import { getAllVersions } from "baseline-browser-mapping";217 218getAllVersions();219```220 221By default, this function returns an `Array` of `Objects` and excludes downstream browsers:222 223```javascript224[225 ...226 {227 browser: "firefox_android", // Browser name228 version: "125", // Browser version229 release_date: "2024-04-16", // Release date230 year: 2023, // Baseline year feature set the version supports231 wa_compatible: true // Whether the browser version supports Widely available232 },233 ...234]235```236 237For browser versions in `@mdn/browser-compat-data` that were released before Baseline can be defined, i.e. Baseline 2015, the `year` property is always the string: `"pre_baseline"`.238 239### Understanding which browsers support Newly available features240 241You may want to understand which recent browser versions support all Newly available features. You can replace the `wa_compatible` property with a `supports` property using the `useSupport` option:242 243```javascript244getAllVersions({245 useSupports: true,246});247```248 249The `supports` property is optional and has two possible values:250 251- `widely` for browser versions that support all Widely available features.252- `newly` for browser versions that support all Newly available features.253 254Browser versions that do not support Widely or Newly available will not include the `support` property in the `array` or `object` outputs, and in the CSV output, the `support` column will contain an empty string. Browser versions that support all Newly available features also support all Widely available features.255 256### `getAllVersions()` Configuration options257 258`getAllVersions()` accepts an `Object` as an argument with configuration options. The defaults are as follows:259 260```javascript261{262 includeDownstreamBrowsers: false,263 outputFormat: "array",264 suppressWarnings: false265}266```267 268#### `includeDownstreamBrowsers` (in `getAllVersions()` output)269 270As with `getCompatibleVersions()`, you can set `includeDownstreamBrowsers` to `true` to include the Chromium and Gecko downstream browsers [listed below](#list-of-downstream-browsers).271 272```javascript273getAllVersions({274 includeDownstreamBrowsers: true,275});276```277 278Downstream browsers include the same properties as core browsers, as well as the `engine`they use and `engine_version`, for example:279 280```javascript281[282 ...283 {284 browser: "samsunginternet_android",285 version: "27.0",286 release_date: "2024-11-06",287 engine: "Blink",288 engine_version: "125",289 year: 2023,290 supports: "widely"291 },292 ...293]294```295 296#### `includeKaiOS` (in `getAllVersions()` output)297 298As with `getCompatibleVersions()` you can include KaiOS in your output. The same requirement to have `includeDownstreamBrowsers: true` applies.299 300```javascript301getAllVersions({302 includeDownstreamBrowsers: true,303 includeKaiOS: true,304});305```306 307#### `suppressWarnings` (in `getAllVersions()` output)308 309As with `getCompatibleVersions()`, you can set `suppressWarnings` to `true` to suppress the console warning about old data:310 311```javascript312getAllVersions({313 suppressWarnings: true,314});315```316 317#### `outputFormat`318 319By default, this function returns an `Array` of `Objects` which can be manipulated in Javascript or output to JSON.320 321To return an `Object` that nests keys , set `outputFormat` to `object`:322 323```javascript324getAllVersions({325 outputFormat: "object",326});327```328 329In thise case, `getAllVersions()` returns a nested object with the browser [IDs listed below](#list-of-downstream-browsers) as keys, and versions as keys within them:330 331```javascript332{333 "chrome": {334 "53": {335 "year": 2016,336 "release_date": "2016-09-07"337 },338 ...339}340```341 342Downstream browsers will include extra fields for `engine` and `engine_versions`343 344```javascript345{346 ...347 "webview_android": {348 "53": {349 "year": 2016,350 "release_date": "2016-09-07",351 "engine": "Blink",352 "engine_version": "53"353 },354 ...355}356```357 358To return a `String` in CSV format, set `outputFormat` to `csv`:359 360```javascript361getAllVersions({362 outputFormat: "csv",363});364```365 366`getAllVersions` returns a `String` with a header row and comma-separated values for each browser version that you can write to a file or pass to another service. Core browsers will have "NULL" as the value for their `engine` and `engine_version`:367 368```csv369"browser","version","year","supports","release_date","engine","engine_version"370...371"chrome","24","pre_baseline","","2013-01-10","NULL","NULL"372...373"chrome","53","2016","","2016-09-07","NULL","NULL"374...375"firefox","135","2024","widely","2025-02-04","NULL","NULL"376"firefox","136","2024","newly","2025-03-04","NULL","NULL"377...378"ya_android","20.12","2020","year_only","2020-12-20","Blink","87"379...380```381 382> [!NOTE]383> The above example uses `"includeDownstreamBrowsers": true`384 385### Static resources386 387The outputs of `getAllVersions()` are available as JSON or CSV files generated on a daily basis and hosted on GitHub pages:388 389- Core browsers only390 - [Array](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_array.json)391 - [Object](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_object.json)392 - [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions.csv)393- Core browsers only, with `supports` property394 - [Array](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_array_with_supports.json)395 - [Object](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_object_with_supports.json)396 - [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/all_versions_with_supports.csv)397- Including downstream browsers398 - [Array](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_array.json)399 - [Object](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_object.json)400 - [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions.csv)401- Including downstream browsers with `supports` property402 - [Array](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_array_with_supports.json)403 - [Object](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_object_with_supports.json)404 - [CSV](https://web-platform-dx.github.io/baseline-browser-mapping/with_downstream/all_versions_with_supports.csv)405 406These files are updated on a daily basis.407 408## CLI409 410`baseline-browser-mapping` includes a command line interface that exposes the same data and options as the `getCompatibleVersions()` function. To learn more about using the CLI, run:411 412```sh413npx baseline-browser-mapping --help414```415 416## Downstream browsers417 418### Limitations419 420The browser versions in this module come from two different sources:421 422- MDN's `browser-compat-data` module.423- Parsed user agent strings provided by [useragents.io](https://useragents.io/)424 425MDN `browser-compat-data` is an authoritative source of information for the browsers it contains. The release dates for the Baseline core browser set and the mapping of downstream browsers to Chromium versions should be considered accurate.426 427Browser mappings from useragents.io are provided on a best effort basis. They assume that browser vendors are accurately stating the Chromium version they have implemented. The initial set of version mappings was derived from a bulk export in November 2024. This version was iterated over with a Regex match looking for a major Chrome version and a corresponding version of the browser in question, e.g.:428 429`Mozilla/5.0 (Linux; U; Android 10; en-US; STK-L21 Build/HUAWEISTK-L21) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/100.0.4896.58 UCBrowser/13.8.2.1324 Mobile Safari/537.36`430 431Shows UC Browser Mobile 13.8 implementing Chromium 100, and:432 433`Mozilla/5.0 (Linux; arm_64; Android 11; Redmi Note 8 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.6613.123 YaBrowser/24.10.2.123.00 SA/3 Mobile Safari/537.36`434 435Shows Yandex Browser Mobile 24.10 implementing Chromium 128. The Chromium version from this string is mapped to the corresponding Chrome version from MDN `browser-compat-data`.436 437> [!NOTE]438> Where possible, approximate release dates have been included based on useragents.io "first seen" data. useragents.io does not have "first seen" dates prior to June 2020. However, these browsers' Baseline compatibility is determined by their Chromium or Gecko version, so their release dates are more informative than critical.439 440This data is updated on a daily basis using a [script](https://github.com/web-platform-dx/web-features/tree/main/scripts/refresh-downstream.ts) triggered by a GitHub [action](https://github.com/web-platform-dx/web-features/tree/main/.github/workflows/refresh_downstream.yml). Useragents.io provides a private API for this module which exposes the last 7 days of newly seen user agents for the currently tracked browsers. If a new major version of one of the tracked browsers is encountered with a Chromium version that meets or exceeds the previous latest version of that browser, it is added to the [src/data/downstream-browsers.json](src/data/downstream-browsers.json) file with the date it was first seen by useragents.io as its release date.441 442KaiOS is an exception - its upstream version mappings are handled separately from the other browsers because they happen very infrequently.443 444### List of downstream browsers445 446| Browser | ID | Core | Source |447| --------------------- | ------------------------- | ------- | ------------------------- |448| Chrome | `chrome` | `true` | MDN `browser-compat-data` |449| Chrome for Android | `chrome_android` | `true` | MDN `browser-compat-data` |450| Edge | `edge` | `true` | MDN `browser-compat-data` |451| Firefox | `firefox` | `true` | MDN `browser-compat-data` |452| Firefox for Android | `firefox_android` | `true` | MDN `browser-compat-data` |453| Safari | `safari` | `true` | MDN `browser-compat-data` |454| Safari on iOS | `safari_ios` | `true` | MDN `browser-compat-data` |455| Opera | `opera` | `false` | MDN `browser-compat-data` |456| Opera Android | `opera_android` | `false` | MDN `browser-compat-data` |457| Samsung Internet | `samsunginternet_android` | `false` | MDN `browser-compat-data` |458| WebView Android | `webview_android` | `false` | MDN `browser-compat-data` |459| QQ Browser Mobile | `qq_android` | `false` | useragents.io |460| UC Browser Mobile | `uc_android` | `false` | useragents.io |461| Yandex Browser Mobile | `ya_android` | `false` | useragents.io |462| KaiOS | `kai_os` | `false` | Manual |463| Facebook for Android | `facebook_android` | `false` | useragents.io |464| Instagram for Android | `instagram_android` | `false` | useragents.io |465 466> [!NOTE]467> All the non-core browsers currently included implement Chromium or Gecko. Their inclusion in any of the above methods is based on the Baseline feature set supported by the Chromium or Gecko version they implement, not their release date.468 