baseline-browser-mapping 2.8.32 → 2.9.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -23,10 +23,18 @@ To install the package, run:
|
|
|
23
23
|
]
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
If your installed version of `baseline-browser-mapping` is greater than 2 months old, you will receive a console warning advising you to update to the latest version.
|
|
27
|
-
|
|
28
26
|
The 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.
|
|
29
27
|
|
|
28
|
+
## Keeping `baseline-browser-mapping` up to date
|
|
29
|
+
|
|
30
|
+
If 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.
|
|
31
|
+
|
|
32
|
+
However, 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 your installed version of `baseline-browser-mapping` is 2 or more months older than the feature compatibility cut off date you are targeting, you will receive a console warning advising you to update to the latest version when you call `getCompatibleVersions()` or `getAllVersions()`.
|
|
33
|
+
|
|
34
|
+
If you want to suppress these warnings 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.
|
|
35
|
+
|
|
36
|
+
If 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 to `baseline widely available on {YYYY-MM-DD}` as part of your build process to ensure the same list of minimum browsers is reproduced for historical builds.
|
|
37
|
+
|
|
30
38
|
## Importing `baseline-browser-mapping`
|
|
31
39
|
|
|
32
40
|
This module exposes two functions: `getCompatibleVersions()` and `getAllVersions()`, both which can be imported directly from `baseline-browser-mapping`:
|
|
@@ -95,7 +103,8 @@ Executed on 7th March 2025, the above code returns the following browser version
|
|
|
95
103
|
targetYear: undefined,
|
|
96
104
|
widelyAvailableOnDate: undefined,
|
|
97
105
|
includeDownstreamBrowsers: false,
|
|
98
|
-
listAllCompatibleVersions: false
|
|
106
|
+
listAllCompatibleVersions: false,
|
|
107
|
+
suppressWarnings: false
|
|
99
108
|
}
|
|
100
109
|
```
|
|
101
110
|
|
|
@@ -185,6 +194,16 @@ getCompatibleVersions({
|
|
|
185
194
|
});
|
|
186
195
|
```
|
|
187
196
|
|
|
197
|
+
#### `suppressWarnings`
|
|
198
|
+
|
|
199
|
+
Setting `suppressWarnings` to `true` will suppress the console warning about old data:
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
getCompatibleVersions({
|
|
203
|
+
suppressWarnings: true,
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
188
207
|
## Get data for all browser versions
|
|
189
208
|
|
|
190
209
|
You 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:
|
|
@@ -237,7 +256,8 @@ Browser versions that do not support Widely or Newly available will not include
|
|
|
237
256
|
```javascript
|
|
238
257
|
{
|
|
239
258
|
includeDownstreamBrowsers: false,
|
|
240
|
-
outputFormat: "array"
|
|
259
|
+
outputFormat: "array",
|
|
260
|
+
suppressWarnings: false
|
|
241
261
|
}
|
|
242
262
|
```
|
|
243
263
|
|
|
@@ -280,6 +300,16 @@ getAllVersions({
|
|
|
280
300
|
});
|
|
281
301
|
```
|
|
282
302
|
|
|
303
|
+
#### `suppressWarnings` (in `getAllVersions()` output)
|
|
304
|
+
|
|
305
|
+
As with `getCompatibleVersions()`, you can set `suppressWarnings` to `true` to suppress the console warning about old data:
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
getAllVersions({
|
|
309
|
+
suppressWarnings: true,
|
|
310
|
+
});
|
|
311
|
+
```
|
|
312
|
+
|
|
283
313
|
#### `outputFormat`
|
|
284
314
|
|
|
285
315
|
By default, this function returns an `Array` of `Objects` which can be manipulated in Javascript or output to JSON.
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{parseArgs as e}from"node:util";import{exit as a}from"node:process";import{getCompatibleVersions as
|
|
2
|
+
import{parseArgs as e}from"node:util";import{exit as a}from"node:process";import{getCompatibleVersions as r}from"./index.js";const s=process.argv.slice(2),{values:i}=e({args:s,options:{"target-year":{type:"string"},"widely-available-on-date":{type:"string"},"include-downstream-browsers":{type:"boolean"},"list-all-compatible-versions":{type:"boolean"},"include-kaios":{type:"boolean"},"override-last-updated":{type:"string"},help:{type:"boolean",short:"h"}},strict:!0});i.help&&(console.log("\nGet Baseline Widely available browser versions or Baseline year browser versions.\n\nUsage: baseline-browser-mapping [options]\n\nOptions:\n --target-year Pass a year between 2015 and the current year to get browser versions compatible \n with all Newly Available features as of the end of the year specified.\n --widely-available-on-date Pass a date in the format 'YYYY-MM-DD' to get versions compatible with Widely \n available on the specified date.\n --include-downstream-browsers Whether to include browsers that use the same engines as a core Baseline browser.\n --include-kaios Whether to include KaiOS in downstream browsers. Requires --include-downstream-browsers.\n --list-all-compatible-versions Whether to include only the minimum compatible browser versions or all compatible versions.\n --override-last-updated Override the last updated date for the baseline data for debugging purposes.\n -h, --help Show help\n\nExamples:\n npx baseline-browser-mapping --target-year 2020\n npx baseline-browser-mapping --widely-available-on-date 2023-04-05\n npx baseline-browser-mapping --include-downstream-browsers\n npx baseline-browser-mapping --list-all-compatible-versions\n".trim()),a(0)),console.log(r({targetYear:i["target-year"]?Number.parseInt(i["target-year"]):void 0,widelyAvailableOnDate:i["widely-available-on-date"],includeDownstreamBrowsers:i["include-downstream-browsers"],listAllCompatibleVersions:i["list-all-compatible-versions"],includeKaiOS:i["include-kaios"],overrideLastUpdated:i["override-last-updated"]?Number.parseInt(i["override-last-updated"]):void 0}));
|