browserslist 4.17.1 → 4.17.5
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 +2 -646
- package/package.json +5 -5
- package/update-db.js +55 -37
package/README.md
CHANGED
|
@@ -62,649 +62,5 @@ Browserslist will take queries from tool option,
|
|
|
62
62
|
[Babel]: https://github.com/babel/babel/tree/master/packages/babel-preset-env
|
|
63
63
|
[obsolete-webpack-plugin]: https://github.com/ElemeFE/obsolete-webpack-plugin
|
|
64
64
|
|
|
65
|
-
##
|
|
66
|
-
|
|
67
|
-
* [Tools](#tools)
|
|
68
|
-
* [Text Editors](#text-editors)
|
|
69
|
-
* [Best Practices](#best-practices)
|
|
70
|
-
* [Browsers Data Updating](#browsers-data-updating)
|
|
71
|
-
* [Queries](#queries)
|
|
72
|
-
* [Query Composition](#query-composition)
|
|
73
|
-
* [Full List](#full-list)
|
|
74
|
-
* [Debug](#debug)
|
|
75
|
-
* [Browsers](#browsers)
|
|
76
|
-
* [Config File](#config-file)
|
|
77
|
-
* [`package.json`](#packagejson)
|
|
78
|
-
* [`.browserslistrc`](#browserslistrc)
|
|
79
|
-
* [Shareable Configs](#shareable-configs)
|
|
80
|
-
* [Configuring for Different Environments](#configuring-for-different-environments)
|
|
81
|
-
* [Custom Usage Data](#custom-usage-data)
|
|
82
|
-
* [JS API](#js-api)
|
|
83
|
-
* [Environment Variables](#environment-variables)
|
|
84
|
-
* [Cache](#cache)
|
|
85
|
-
* [Security Contact](#security-contact)
|
|
86
|
-
* [For Enterprise](#for-enterprise)
|
|
87
|
-
|
|
88
|
-
## Tools
|
|
89
|
-
|
|
90
|
-
* [`browserl.ist`](https://browserl.ist/) is an online tool to check
|
|
91
|
-
what browsers will be selected by some query.
|
|
92
|
-
* [`browserslist-ga`] and [`browserslist-ga-export`] download your website
|
|
93
|
-
browsers statistics to use it in `> 0.5% in my stats` query.
|
|
94
|
-
* [`browserslist-useragent-regexp`] compiles Browserslist query to a RegExp
|
|
95
|
-
to test browser useragent.
|
|
96
|
-
* [`browserslist-useragent-ruby`] is a Ruby library to checks browser
|
|
97
|
-
by user agent string to match Browserslist.
|
|
98
|
-
* [`browserslist-browserstack`] runs BrowserStack tests for all browsers
|
|
99
|
-
in Browserslist config.
|
|
100
|
-
* [`browserslist-adobe-analytics`] use Adobe Analytics data to target browsers.
|
|
101
|
-
* [`browserslist-new-relic`] generate a custom usage data file for Browserslist
|
|
102
|
-
from your New Relic Browser data.
|
|
103
|
-
* [`caniuse-api`] returns browsers which support some specific feature.
|
|
104
|
-
* Run `npx browserslist` in your project directory to see project’s
|
|
105
|
-
target browsers. This CLI tool is built-in and available in any project
|
|
106
|
-
with Autoprefixer.
|
|
107
|
-
|
|
108
|
-
[`browserslist-useragent-regexp`]: https://github.com/browserslist/browserslist-useragent-regexp
|
|
109
|
-
[`browserslist-adobe-analytics`]: https://github.com/xeroxinteractive/browserslist-adobe-analytics
|
|
110
|
-
[`browserslist-useragent-ruby`]: https://github.com/browserslist/browserslist-useragent-ruby
|
|
111
|
-
[`browserslist-browserstack`]: https://github.com/xeroxinteractive/browserslist-browserstack
|
|
112
|
-
[`browserslist-ga-export`]: https://github.com/browserslist/browserslist-ga-export
|
|
113
|
-
[`browserslist-useragent`]: https://github.com/pastelsky/browserslist-useragent
|
|
114
|
-
[`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
|
|
115
|
-
[`browserslist-new-relic`]: https://github.com/syntactic-salt/browserslist-new-relic
|
|
116
|
-
[`caniuse-api`]: https://github.com/Nyalab/caniuse-api
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
### Text Editors
|
|
120
|
-
|
|
121
|
-
These extensions will add syntax highlighting for `.browserslistrc` files.
|
|
122
|
-
|
|
123
|
-
* [VS Code](https://marketplace.visualstudio.com/items?itemName=webben.browserslist)
|
|
124
|
-
* [Vim](https://github.com/browserslist/vim-browserslist)
|
|
125
|
-
|
|
126
|
-
## Best Practices
|
|
127
|
-
|
|
128
|
-
* There is a `defaults` query, which gives a reasonable configuration
|
|
129
|
-
for most users:
|
|
130
|
-
|
|
131
|
-
```json
|
|
132
|
-
"browserslist": [
|
|
133
|
-
"defaults"
|
|
134
|
-
]
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
* If you want to change the default set of browsers, we recommend combining
|
|
138
|
-
`last 2 versions`, `not dead` with a usage number like `> 0.2%`. This is
|
|
139
|
-
because `last n versions` on its own does not add popular old versions, while
|
|
140
|
-
only using a percentage above `0.2%` will in the long run make popular
|
|
141
|
-
browsers even more popular. We might run into a monopoly and stagnation
|
|
142
|
-
situation, as we had with Internet Explorer 6. Please use this setting
|
|
143
|
-
with caution.
|
|
144
|
-
* Select browsers directly (`last 2 Chrome versions`) only if you are making
|
|
145
|
-
a web app for a kiosk with one browser. There are a lot of browsers
|
|
146
|
-
on the market. If you are making general web app you should respect
|
|
147
|
-
browsers diversity.
|
|
148
|
-
* Don’t remove browsers just because you don’t know them. Opera Mini has
|
|
149
|
-
100 million users in Africa and it is more popular in the global market
|
|
150
|
-
than Microsoft Edge. Chinese QQ Browsers has more market share than Firefox
|
|
151
|
-
and desktop Safari combined.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
## Browsers Data Updating
|
|
155
|
-
|
|
156
|
-
`npx browserslist@latest --update-db` updates `caniuse-lite` version
|
|
157
|
-
in your npm, yarn or pnpm lock file.
|
|
158
|
-
|
|
159
|
-
You need to do it regularly for two reasons:
|
|
160
|
-
|
|
161
|
-
1. To use the latest browser’s versions and statistics in queries like
|
|
162
|
-
`last 2 versions` or `>1%`. For example, if you created your project
|
|
163
|
-
2 years ago and did not update your dependencies, `last 1 version`
|
|
164
|
-
will return 2 year old browsers.
|
|
165
|
-
2. `caniuse-lite` deduplication: to synchronize version in different tools.
|
|
166
|
-
|
|
167
|
-
> What is deduplication?
|
|
168
|
-
|
|
169
|
-
Due to how npm architecture is setup, you may have a situation
|
|
170
|
-
where you have multiple versions of a single dependency required.
|
|
171
|
-
|
|
172
|
-
Imagine you begin a project, and you add `autoprefixer` as a dependency.
|
|
173
|
-
npm looks for the latest `caniuse-lite` version (1.0.30000700) and adds it to
|
|
174
|
-
`package-lock.json` under `autoprefixer` dependencies.
|
|
175
|
-
|
|
176
|
-
A year later, you decide to add Babel. At this moment, we have a
|
|
177
|
-
new version of `canuse-lite` (1.0.30000900). npm took the latest version
|
|
178
|
-
and added it to your lock file under `@babel/preset-env` dependencies.
|
|
179
|
-
|
|
180
|
-
Now your lock file looks like this:
|
|
181
|
-
|
|
182
|
-
```ocaml
|
|
183
|
-
autoprefixer 7.1.4
|
|
184
|
-
browserslist 3.1.1
|
|
185
|
-
caniuse-lite 1.0.30000700
|
|
186
|
-
@babel/preset-env 7.10.0
|
|
187
|
-
browserslist 4.13.0
|
|
188
|
-
caniuse-lite 1.0.30000900
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
As you can see, we now have two versions of `caniuse-lite` installed.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
## Queries
|
|
195
|
-
|
|
196
|
-
Browserslist will use browsers and Node.js versions query
|
|
197
|
-
from one of these sources:
|
|
198
|
-
|
|
199
|
-
1. `browserslist` key in `package.json` file in current or parent directories.
|
|
200
|
-
**We recommend this way.**
|
|
201
|
-
2. `.browserslistrc` config file in current or parent directories.
|
|
202
|
-
3. `browserslist` config file in current or parent directories.
|
|
203
|
-
4. `BROWSERSLIST` environment variable.
|
|
204
|
-
5. If the above methods did not produce a valid result
|
|
205
|
-
Browserslist will use defaults:
|
|
206
|
-
`> 0.5%, last 2 versions, Firefox ESR, not dead`.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
### Query Composition
|
|
210
|
-
|
|
211
|
-
An `or` combiner can use the keyword `or` as well as `,`.
|
|
212
|
-
`last 1 version or > 1%` is equal to `last 1 version, > 1%`.
|
|
213
|
-
|
|
214
|
-
`and` query combinations are also supported to perform an
|
|
215
|
-
intersection of all the previous queries:
|
|
216
|
-
`last 1 version or chrome > 75 and > 1%` will select
|
|
217
|
-
(`browser last version` or `Chrome since 76`) and `more than 1% marketshare`.
|
|
218
|
-
|
|
219
|
-
There are 3 different ways to combine queries as depicted below. First you start
|
|
220
|
-
with a single query and then we combine the queries to get our final list.
|
|
221
|
-
|
|
222
|
-
Obviously you can *not* start with a `not` combiner, since there is no left-hand
|
|
223
|
-
side query to combine it with. The left-hand is always resolved as `and`
|
|
224
|
-
combiner even if `or` is used (this is an API implementation specificity).
|
|
225
|
-
|
|
226
|
-
| Query combiner type | Illustration | Example |
|
|
227
|
-
| ------------------- | :----------: | ------- |
|
|
228
|
-
|`or`/`,` combiner <br> (union) |  | `> .5% or last 2 versions` <br> `> .5%, last 2 versions` |
|
|
229
|
-
| `and` combiner <br> (intersection) |  | `> .5% and last 2 versions` |
|
|
230
|
-
| `not` combiner <br> (relative complement) |  | All those three are equivalent to the first one <br> `> .5% and not last 2 versions` <br> `> .5% or not last 2 versions` <br> `> .5%, not last 2 versions` |
|
|
231
|
-
|
|
232
|
-
_A quick way to test your query is to do `npx browserslist '> 0.5%, not IE 11'`
|
|
233
|
-
in your terminal._
|
|
234
|
-
|
|
235
|
-
### Full List
|
|
236
|
-
|
|
237
|
-
You can specify the browser and Node.js versions by queries (case insensitive):
|
|
238
|
-
|
|
239
|
-
* `defaults`: Browserslist’s default browsers
|
|
240
|
-
(`> 0.5%, last 2 versions, Firefox ESR, not dead`).
|
|
241
|
-
* By usage statistics:
|
|
242
|
-
* `> 5%`: browsers versions selected by global usage statistics.
|
|
243
|
-
`>=`, `<` and `<=` work too.
|
|
244
|
-
* `> 5% in US`: uses USA usage statistics.
|
|
245
|
-
It accepts [two-letter country code].
|
|
246
|
-
* `> 5% in alt-AS`: uses Asia region usage statistics.
|
|
247
|
-
List of all region codes can be found at [`caniuse-lite/data/regions`].
|
|
248
|
-
* `> 5% in my stats`: uses [custom usage data].
|
|
249
|
-
* `> 5% in browserslist-config-mycompany stats`: uses [custom usage data]
|
|
250
|
-
from `browserslist-config-mycompany/browserslist-stats.json`.
|
|
251
|
-
* `cover 99.5%`: most popular browsers that provide coverage.
|
|
252
|
-
* `cover 99.5% in US`: same as above, with [two-letter country code].
|
|
253
|
-
* `cover 99.5% in my stats`: uses [custom usage data].
|
|
254
|
-
* Last versions:
|
|
255
|
-
* `last 2 versions`: the last 2 versions for *each* browser.
|
|
256
|
-
* `last 2 Chrome versions`: the last 2 versions of Chrome browser.
|
|
257
|
-
* `last 2 major versions` or `last 2 iOS major versions`:
|
|
258
|
-
all minor/patch releases of last 2 major versions.
|
|
259
|
-
* `dead`: browsers without official support or updates for 24 months.
|
|
260
|
-
Right now it is `IE 10`, `IE_Mob 11`, `BlackBerry 10`, `BlackBerry 7`,
|
|
261
|
-
`Samsung 4` and `OperaMobile 12.1`.
|
|
262
|
-
* Node.js versions:
|
|
263
|
-
* `node 10` and `node 10.4`: selects latest Node.js `10.x.x`
|
|
264
|
-
or `10.4.x` release.
|
|
265
|
-
* `current node`: Node.js version used by Browserslist right now.
|
|
266
|
-
* `maintained node versions`: all Node.js versions, which are [still maintained]
|
|
267
|
-
by Node.js Foundation.
|
|
268
|
-
* Browsers versions:
|
|
269
|
-
* `iOS 7`: the iOS browser version 7 directly.
|
|
270
|
-
* `Firefox > 20`: versions of Firefox newer than 20.
|
|
271
|
-
`>=`, `<` and `<=` work too. It also works with Node.js.
|
|
272
|
-
* `ie 6-8`: selects an inclusive range of versions.
|
|
273
|
-
* `Firefox ESR`: the latest [Firefox Extended Support Release].
|
|
274
|
-
* `PhantomJS 2.1` and `PhantomJS 1.9`: selects Safari versions similar
|
|
275
|
-
to PhantomJS runtime.
|
|
276
|
-
* `extends browserslist-config-mycompany`: take queries from
|
|
277
|
-
`browserslist-config-mycompany` npm package.
|
|
278
|
-
* `supports es6-module`: browsers with support for specific features.
|
|
279
|
-
`es6-module` here is the `feat` parameter at the URL of the [Can I Use]
|
|
280
|
-
page. A list of all available features can be found at
|
|
281
|
-
[`caniuse-lite/data/features`].
|
|
282
|
-
* `browserslist config`: the browsers defined in Browserslist config. Useful
|
|
283
|
-
in Differential Serving to modify user’s config like
|
|
284
|
-
`browserslist config and supports es6-module`.
|
|
285
|
-
* `since 2015` or `last 2 years`: all versions released since year 2015
|
|
286
|
-
(also `since 2015-03` and `since 2015-03-10`).
|
|
287
|
-
* `unreleased versions` or `unreleased Chrome versions`:
|
|
288
|
-
alpha and beta versions.
|
|
289
|
-
* `not ie <= 8`: exclude IE 8 and lower from previous queries.
|
|
290
|
-
|
|
291
|
-
You can add `not ` to any query.
|
|
292
|
-
|
|
293
|
-
[`caniuse-lite/data/regions`]: https://github.com/ben-eb/caniuse-lite/tree/master/data/regions
|
|
294
|
-
[`caniuse-lite/data/features`]: https://github.com/ben-eb/caniuse-lite/tree/master/data/features
|
|
295
|
-
[two-letter country code]: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements
|
|
296
|
-
[custom usage data]: #custom-usage-data
|
|
297
|
-
[still maintained]: https://github.com/nodejs/Release
|
|
298
|
-
[Can I Use]: https://caniuse.com/
|
|
299
|
-
[Firefox Extended Support Release]: https://support.mozilla.org/en-US/kb/choosing-firefox-update-channel
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
### Debug
|
|
303
|
-
|
|
304
|
-
Run `npx browserslist` in project directory to see what browsers was selected
|
|
305
|
-
by your queries.
|
|
306
|
-
|
|
307
|
-
```sh
|
|
308
|
-
$ npx browserslist
|
|
309
|
-
and_chr 61
|
|
310
|
-
and_ff 56
|
|
311
|
-
and_qq 1.2
|
|
312
|
-
and_uc 11.4
|
|
313
|
-
android 56
|
|
314
|
-
baidu 7.12
|
|
315
|
-
bb 10
|
|
316
|
-
chrome 62
|
|
317
|
-
edge 16
|
|
318
|
-
firefox 56
|
|
319
|
-
ios_saf 11
|
|
320
|
-
opera 48
|
|
321
|
-
safari 11
|
|
322
|
-
samsung 5
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
### Browsers
|
|
327
|
-
|
|
328
|
-
Names are case insensitive:
|
|
329
|
-
|
|
330
|
-
* `Android` for Android WebView.
|
|
331
|
-
* `Baidu` for Baidu Browser.
|
|
332
|
-
* `BlackBerry` or `bb` for Blackberry browser.
|
|
333
|
-
* `Chrome` for Google Chrome.
|
|
334
|
-
* `ChromeAndroid` or `and_chr` for Chrome for Android
|
|
335
|
-
* `Edge` for Microsoft Edge.
|
|
336
|
-
* `Electron` for Electron framework. It will be converted to Chrome version.
|
|
337
|
-
* `Explorer` or `ie` for Internet Explorer.
|
|
338
|
-
* `ExplorerMobile` or `ie_mob` for Internet Explorer Mobile.
|
|
339
|
-
* `Firefox` or `ff` for Mozilla Firefox.
|
|
340
|
-
* `FirefoxAndroid` or `and_ff` for Firefox for Android.
|
|
341
|
-
* `iOS` or `ios_saf` for iOS Safari.
|
|
342
|
-
* `Node` for Node.js.
|
|
343
|
-
* `Opera` for Opera.
|
|
344
|
-
* `OperaMini` or `op_mini` for Opera Mini.
|
|
345
|
-
* `OperaMobile` or `op_mob` for Opera Mobile.
|
|
346
|
-
* `QQAndroid` or `and_qq` for QQ Browser for Android.
|
|
347
|
-
* `Safari` for desktop Safari.
|
|
348
|
-
* `Samsung` for Samsung Internet.
|
|
349
|
-
* `UCAndroid` or `and_uc` for UC Browser for Android.
|
|
350
|
-
* `kaios` for KaiOS Browser.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
## Config File
|
|
354
|
-
|
|
355
|
-
### `package.json`
|
|
356
|
-
|
|
357
|
-
If you want to reduce config files in project root, you can specify
|
|
358
|
-
browsers in `package.json` with `browserslist` key:
|
|
359
|
-
|
|
360
|
-
```json
|
|
361
|
-
{
|
|
362
|
-
"private": true,
|
|
363
|
-
"dependencies": {
|
|
364
|
-
"autoprefixer": "^6.5.4"
|
|
365
|
-
},
|
|
366
|
-
"browserslist": [
|
|
367
|
-
"last 1 version",
|
|
368
|
-
"> 1%",
|
|
369
|
-
"IE 10"
|
|
370
|
-
]
|
|
371
|
-
}
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
### `.browserslistrc`
|
|
376
|
-
|
|
377
|
-
Separated Browserslist config should be named `.browserslistrc`
|
|
378
|
-
and have browsers queries split by a new line.
|
|
379
|
-
Each line is combined with the `or` combiner. Comments starts with `#` symbol:
|
|
380
|
-
|
|
381
|
-
```yaml
|
|
382
|
-
# Browsers that we support
|
|
383
|
-
|
|
384
|
-
last 1 version
|
|
385
|
-
> 1%
|
|
386
|
-
IE 10 # sorry
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
Browserslist will check config in every directory in `path`.
|
|
390
|
-
So, if tool process `app/styles/main.css`, you can put config to root,
|
|
391
|
-
`app/` or `app/styles`.
|
|
392
|
-
|
|
393
|
-
You can specify direct path in `BROWSERSLIST_CONFIG` environment variables.
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
## Shareable Configs
|
|
397
|
-
|
|
398
|
-
You can use the following query to reference an exported Browserslist config
|
|
399
|
-
from another package:
|
|
400
|
-
|
|
401
|
-
```json
|
|
402
|
-
"browserslist": [
|
|
403
|
-
"extends browserslist-config-mycompany"
|
|
404
|
-
]
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
For security reasons, external configuration only supports packages that have
|
|
408
|
-
the `browserslist-config-` prefix. npm scoped packages are also supported, by
|
|
409
|
-
naming or prefixing the module with `@scope/browserslist-config`, such as
|
|
410
|
-
`@scope/browserslist-config` or `@scope/browserslist-config-mycompany`.
|
|
411
|
-
|
|
412
|
-
If you don’t accept Browserslist queries from users, you can disable the
|
|
413
|
-
validation by using the or `BROWSERSLIST_DANGEROUS_EXTEND` environment variable.
|
|
414
|
-
|
|
415
|
-
```sh
|
|
416
|
-
BROWSERSLIST_DANGEROUS_EXTEND=1 npx webpack
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
Because this uses `npm`'s resolution, you can also reference specific files
|
|
420
|
-
in a package:
|
|
421
|
-
|
|
422
|
-
```json
|
|
423
|
-
"browserslist": [
|
|
424
|
-
"extends browserslist-config-mycompany/desktop",
|
|
425
|
-
"extends browserslist-config-mycompany/mobile"
|
|
426
|
-
]
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
When writing a shared Browserslist package, just export an array.
|
|
430
|
-
`browserslist-config-mycompany/index.js`:
|
|
431
|
-
|
|
432
|
-
```js
|
|
433
|
-
module.exports = [
|
|
434
|
-
'last 1 version',
|
|
435
|
-
'> 1%',
|
|
436
|
-
'ie 10'
|
|
437
|
-
]
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
You can also include a `browserslist-stats.json` file as part of your shareable
|
|
441
|
-
config at the root and query it using
|
|
442
|
-
`> 5% in browserslist-config-mycompany stats`. It uses the same format
|
|
443
|
-
as `extends` and the `dangerousExtend` property as above.
|
|
444
|
-
|
|
445
|
-
You can export configs for different environments and select environment
|
|
446
|
-
by `BROWSERSLIST_ENV` or `env` option in your tool:
|
|
447
|
-
|
|
448
|
-
```js
|
|
449
|
-
module.exports = {
|
|
450
|
-
development: [
|
|
451
|
-
'last 1 version'
|
|
452
|
-
],
|
|
453
|
-
production: [
|
|
454
|
-
'last 1 version',
|
|
455
|
-
'> 1%',
|
|
456
|
-
'ie 10'
|
|
457
|
-
]
|
|
458
|
-
}
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
## Configuring for Different Environments
|
|
463
|
-
|
|
464
|
-
You can also specify different browser queries for various environments.
|
|
465
|
-
Browserslist will choose query according to `BROWSERSLIST_ENV` or `NODE_ENV`
|
|
466
|
-
variables. If none of them is declared, Browserslist will firstly look
|
|
467
|
-
for `production` queries and then use defaults.
|
|
468
|
-
|
|
469
|
-
In `package.json`:
|
|
470
|
-
|
|
471
|
-
```js
|
|
472
|
-
"browserslist": {
|
|
473
|
-
"production": [
|
|
474
|
-
"> 1%",
|
|
475
|
-
"ie 10"
|
|
476
|
-
],
|
|
477
|
-
"modern": [
|
|
478
|
-
"last 1 chrome version",
|
|
479
|
-
"last 1 firefox version"
|
|
480
|
-
],
|
|
481
|
-
"ssr": [
|
|
482
|
-
"node 12"
|
|
483
|
-
]
|
|
484
|
-
}
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
In `.browserslistrc` config:
|
|
488
|
-
|
|
489
|
-
```ini
|
|
490
|
-
[production]
|
|
491
|
-
> 1%
|
|
492
|
-
ie 10
|
|
493
|
-
|
|
494
|
-
[modern]
|
|
495
|
-
last 1 chrome version
|
|
496
|
-
last 1 firefox version
|
|
497
|
-
|
|
498
|
-
[ssr]
|
|
499
|
-
node 12
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
## Custom Usage Data
|
|
504
|
-
|
|
505
|
-
If you have a website, you can query against the usage statistics of your site.
|
|
506
|
-
[`browserslist-ga`] will ask access to Google Analytics and then generate
|
|
507
|
-
`browserslist-stats.json`:
|
|
508
|
-
|
|
509
|
-
```
|
|
510
|
-
npx browserslist-ga
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
Or you can use [`browserslist-ga-export`] to convert Google Analytics data without giving a password for Google account.
|
|
514
|
-
|
|
515
|
-
You can generate usage statistics file by any other method. File format should
|
|
516
|
-
be like:
|
|
517
|
-
|
|
518
|
-
```js
|
|
519
|
-
{
|
|
520
|
-
"ie": {
|
|
521
|
-
"6": 0.01,
|
|
522
|
-
"7": 0.4,
|
|
523
|
-
"8": 1.5
|
|
524
|
-
},
|
|
525
|
-
"chrome": {
|
|
526
|
-
…
|
|
527
|
-
},
|
|
528
|
-
…
|
|
529
|
-
}
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
Note that you can query against your custom usage data while also querying
|
|
533
|
-
against global or regional data. For example, the query
|
|
534
|
-
`> 1% in my stats, > 5% in US, 10%` is permitted.
|
|
535
|
-
|
|
536
|
-
[`browserslist-ga-export`]: https://github.com/browserslist/browserslist-ga-export
|
|
537
|
-
[`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
|
|
538
|
-
[Can I Use]: https://caniuse.com/
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
## JS API
|
|
542
|
-
|
|
543
|
-
```js
|
|
544
|
-
const browserslist = require('browserslist')
|
|
545
|
-
|
|
546
|
-
// Your CSS/JS build tool code
|
|
547
|
-
function process (source, opts) {
|
|
548
|
-
const browsers = browserslist(opts.overrideBrowserslist, {
|
|
549
|
-
stats: opts.stats,
|
|
550
|
-
path: opts.file,
|
|
551
|
-
env: opts.env
|
|
552
|
-
})
|
|
553
|
-
// Your code to add features for selected browsers
|
|
554
|
-
}
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
Queries can be a string `"> 1%, IE 10"`
|
|
558
|
-
or an array `['> 1%', 'IE 10']`.
|
|
559
|
-
|
|
560
|
-
If a query is missing, Browserslist will look for a config file.
|
|
561
|
-
You can provide a `path` option (that can be a file) to find the config file
|
|
562
|
-
relatively to it.
|
|
563
|
-
|
|
564
|
-
Options:
|
|
565
|
-
|
|
566
|
-
* `path`: file or a directory path to look for config file. Default is `.`.
|
|
567
|
-
* `env`: what environment section use from config. Default is `production`.
|
|
568
|
-
* `stats`: custom usage statistics data.
|
|
569
|
-
* `config`: path to config if you want to set it manually.
|
|
570
|
-
* `ignoreUnknownVersions`: do not throw on direct query (like `ie 12`).
|
|
571
|
-
Default is `false`.
|
|
572
|
-
* `dangerousExtend`: Disable security checks for `extend` query.
|
|
573
|
-
Default is `false`.
|
|
574
|
-
* `mobileToDesktop`: Use desktop browsers if Can I Use doesn’t have data
|
|
575
|
-
about this mobile version. Can I Use has only data only about
|
|
576
|
-
latest versions of mobile browsers. By default, `last 2 and_ff versions`
|
|
577
|
-
returns `and_ff 90` and with this option it returns `and_ff 91, and_ff 90`.
|
|
578
|
-
This option may lead to unknown browser version error (in example Can I Use
|
|
579
|
-
doesn’t have data for `and_ff 91` yet). Default is `false`.
|
|
580
|
-
|
|
581
|
-
For non-JS environment and debug purpose you can use CLI tool:
|
|
582
|
-
|
|
583
|
-
```sh
|
|
584
|
-
browserslist "> 1%, IE 10"
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
You can get total users coverage for selected browsers by JS API:
|
|
588
|
-
|
|
589
|
-
```js
|
|
590
|
-
browserslist.coverage(browserslist('> 1%'))
|
|
591
|
-
//=> 81.4
|
|
592
|
-
```
|
|
593
|
-
|
|
594
|
-
```js
|
|
595
|
-
browserslist.coverage(browserslist('> 1% in US'), 'US')
|
|
596
|
-
//=> 83.1
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
```js
|
|
600
|
-
browserslist.coverage(browserslist('> 1% in my stats'), 'my stats')
|
|
601
|
-
//=> 83.1
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
```js
|
|
605
|
-
browserslist.coverage(browserslist('> 1% in my stats', { stats }), stats)
|
|
606
|
-
//=> 82.2
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
Or by CLI:
|
|
610
|
-
|
|
611
|
-
```sh
|
|
612
|
-
$ browserslist --coverage "> 1%"
|
|
613
|
-
These browsers account for 81.4% of all users globally
|
|
614
|
-
```
|
|
615
|
-
|
|
616
|
-
```sh
|
|
617
|
-
$ browserslist --coverage=US "> 1% in US"
|
|
618
|
-
These browsers account for 83.1% of all users in the US
|
|
619
|
-
```
|
|
620
|
-
|
|
621
|
-
```sh
|
|
622
|
-
$ browserslist --coverage "> 1% in my stats"
|
|
623
|
-
These browsers account for 83.1% of all users in custom statistics
|
|
624
|
-
```
|
|
625
|
-
|
|
626
|
-
```sh
|
|
627
|
-
$ browserslist --coverage "> 1% in my stats" --stats=./stats.json
|
|
628
|
-
These browsers account for 83.1% of all users in custom statistics
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
## Environment Variables
|
|
633
|
-
|
|
634
|
-
If a tool uses Browserslist inside, you can change the Browserslist settings
|
|
635
|
-
with [environment variables]:
|
|
636
|
-
|
|
637
|
-
* `BROWSERSLIST` with browsers queries.
|
|
638
|
-
|
|
639
|
-
```sh
|
|
640
|
-
BROWSERSLIST="> 5%" npx webpack
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
* `BROWSERSLIST_CONFIG` with path to config file.
|
|
644
|
-
|
|
645
|
-
```sh
|
|
646
|
-
BROWSERSLIST_CONFIG=./config/browserslist npx webpack
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
* `BROWSERSLIST_ENV` with environments string.
|
|
650
|
-
|
|
651
|
-
```sh
|
|
652
|
-
BROWSERSLIST_ENV="development" npx webpack
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
* `BROWSERSLIST_STATS` with path to the custom usage data
|
|
656
|
-
for `> 1% in my stats` query.
|
|
657
|
-
|
|
658
|
-
```sh
|
|
659
|
-
BROWSERSLIST_STATS=./config/usage_data.json npx webpack
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
* `BROWSERSLIST_DISABLE_CACHE` if you want to disable config reading cache.
|
|
663
|
-
|
|
664
|
-
```sh
|
|
665
|
-
BROWSERSLIST_DISABLE_CACHE=1 npx webpack
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
* `BROWSERSLIST_DANGEROUS_EXTEND` to disable security shareable config
|
|
669
|
-
name check.
|
|
670
|
-
|
|
671
|
-
```sh
|
|
672
|
-
BROWSERSLIST_DANGEROUS_EXTEND=1 npx webpack
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
[environment variables]: https://en.wikipedia.org/wiki/Environment_variable
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
## Cache
|
|
679
|
-
|
|
680
|
-
Browserslist caches the configuration it reads from `package.json` and
|
|
681
|
-
`browserslist` files, as well as knowledge about the existence of files,
|
|
682
|
-
for the duration of the hosting process.
|
|
683
|
-
|
|
684
|
-
To clear these caches, use:
|
|
685
|
-
|
|
686
|
-
```js
|
|
687
|
-
browserslist.clearCaches()
|
|
688
|
-
```
|
|
689
|
-
|
|
690
|
-
To disable the caching altogether, set the `BROWSERSLIST_DISABLE_CACHE`
|
|
691
|
-
environment variable.
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
## Security Contact
|
|
695
|
-
|
|
696
|
-
To report a security vulnerability, please use the [Tidelift security contact].
|
|
697
|
-
Tidelift will coordinate the fix and disclosure.
|
|
698
|
-
|
|
699
|
-
[Tidelift security contact]: https://tidelift.com/security
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
## For Enterprise
|
|
703
|
-
|
|
704
|
-
Available as part of the Tidelift Subscription.
|
|
705
|
-
|
|
706
|
-
The maintainers of `browserslist` and thousands of other packages are working
|
|
707
|
-
with Tidelift to deliver commercial support and maintenance for the open source
|
|
708
|
-
dependencies you use to build your applications. Save time, reduce risk,
|
|
709
|
-
and improve code health, while paying the maintainers of the exact dependencies
|
|
710
|
-
you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-browserslist?utm_source=npm-browserslist&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
65
|
+
## Docs
|
|
66
|
+
Read **[full docs](https://github.com/browserslist/browserslist#readme)** on GitHub.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browserslist",
|
|
3
|
-
"version": "4.17.
|
|
3
|
+
"version": "4.17.5",
|
|
4
4
|
"description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"caniuse",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"repository": "browserslist/browserslist",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"caniuse-lite": "^1.0.
|
|
19
|
-
"electron-to-chromium": "^1.3.
|
|
18
|
+
"caniuse-lite": "^1.0.30001271",
|
|
19
|
+
"electron-to-chromium": "^1.3.878",
|
|
20
20
|
"escalade": "^3.1.1",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"node-releases": "^2.0.1",
|
|
22
|
+
"picocolors": "^1.0.0"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
|
package/update-db.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
var childProcess = require('child_process')
|
|
2
|
-
var nanocolors = require('nanocolors')
|
|
3
2
|
var escalade = require('escalade/sync')
|
|
3
|
+
var pico = require('picocolors')
|
|
4
4
|
var path = require('path')
|
|
5
5
|
var fs = require('fs')
|
|
6
6
|
|
|
7
7
|
var BrowserslistError = require('./error')
|
|
8
8
|
|
|
9
|
-
var red = nanocolors.red
|
|
10
|
-
var bold = nanocolors.bold
|
|
11
|
-
var green = nanocolors.green
|
|
12
|
-
var yellow = nanocolors.yellow
|
|
13
|
-
|
|
14
9
|
function detectLockfile () {
|
|
15
10
|
var packageDir = escalade('.', function (dir, names) {
|
|
16
11
|
return names.indexOf('package.json') !== -1 ? dir : ''
|
|
@@ -97,9 +92,9 @@ function diffBrowsersLists (old, current) {
|
|
|
97
92
|
return intersection.indexOf(version) === -1
|
|
98
93
|
})
|
|
99
94
|
return removedVersions.map(function (version) {
|
|
100
|
-
return red('- ' + browser + ' ' + version)
|
|
95
|
+
return pico.red('- ' + browser + ' ' + version)
|
|
101
96
|
}).concat(addedVersions.map(function (version) {
|
|
102
|
-
return green('+ ' + browser + ' ' + version)
|
|
97
|
+
return pico.green('+ ' + browser + ' ' + version)
|
|
103
98
|
}))
|
|
104
99
|
})
|
|
105
100
|
.reduce(function (result, array) {
|
|
@@ -169,7 +164,19 @@ function updatePnpmLockfile (lock, latest) {
|
|
|
169
164
|
for (i = 0; i < lines.length; i++) {
|
|
170
165
|
if (lines[i].indexOf('caniuse-lite:') >= 0) {
|
|
171
166
|
lineParts = lines[i].split(/:\s?/, 2)
|
|
172
|
-
|
|
167
|
+
if (lineParts[1].indexOf('/') >= 0) {
|
|
168
|
+
var sublineParts = lineParts[1].split(/([/:])/)
|
|
169
|
+
for (j = 0; j < sublineParts.length; j++) {
|
|
170
|
+
if (sublineParts[j].indexOf('caniuse-lite') >= 0) {
|
|
171
|
+
versions[sublineParts[j + 2]] = true
|
|
172
|
+
sublineParts[j + 2] = latest.version
|
|
173
|
+
break
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
lineParts[1] = sublineParts.join('')
|
|
177
|
+
} else {
|
|
178
|
+
versions[lineParts[1]] = true
|
|
179
|
+
}
|
|
173
180
|
lines[i] = lineParts[0] + ': ' + latest.version
|
|
174
181
|
} else if (lines[i].indexOf('/caniuse-lite') >= 0) {
|
|
175
182
|
lineParts = lines[i].split(/([/:])/)
|
|
@@ -184,7 +191,8 @@ function updatePnpmLockfile (lock, latest) {
|
|
|
184
191
|
for (i = i + 1; i < lines.length; i++) {
|
|
185
192
|
if (lines[i].indexOf('integrity: ') !== -1) {
|
|
186
193
|
lines[i] = lines[i].replace(
|
|
187
|
-
/integrity: .+/,
|
|
194
|
+
/integrity: .+/,
|
|
195
|
+
'integrity: ' + latest.dist.integrity
|
|
188
196
|
)
|
|
189
197
|
} else if (lines[i].indexOf(' /') !== -1) {
|
|
190
198
|
break
|
|
@@ -209,11 +217,13 @@ function updateLockfile (lock, latest) {
|
|
|
209
217
|
function updatePackageManually (print, lock, latest) {
|
|
210
218
|
var lockfileData = updateLockfile(lock, latest)
|
|
211
219
|
var caniuseVersions = Object.keys(lockfileData.versions).sort()
|
|
212
|
-
if (caniuseVersions.length === 1 &&
|
|
213
|
-
caniuseVersions[0] === latest.version) {
|
|
220
|
+
if (caniuseVersions.length === 1 && caniuseVersions[0] === latest.version) {
|
|
214
221
|
print(
|
|
215
|
-
'Installed version: ' +
|
|
216
|
-
|
|
222
|
+
'Installed version: ' +
|
|
223
|
+
pico.bold(pico.green(latest.version)) +
|
|
224
|
+
'\n' +
|
|
225
|
+
pico.bold(pico.green('caniuse-lite is up to date')) +
|
|
226
|
+
'\n'
|
|
217
227
|
)
|
|
218
228
|
return
|
|
219
229
|
}
|
|
@@ -223,27 +233,31 @@ function updatePackageManually (print, lock, latest) {
|
|
|
223
233
|
}
|
|
224
234
|
print(
|
|
225
235
|
'Installed version' +
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
(caniuseVersions.length === 1 ? ': ' : 's: ') +
|
|
237
|
+
pico.bold(pico.red(caniuseVersions.join(', '))) +
|
|
238
|
+
'\n' +
|
|
239
|
+
'Removing old caniuse-lite from lock file\n'
|
|
230
240
|
)
|
|
231
241
|
fs.writeFileSync(lock.file, lockfileData.content)
|
|
232
242
|
|
|
233
243
|
var install = lock.mode === 'yarn' ? 'yarn add -W' : lock.mode + ' install'
|
|
234
244
|
print(
|
|
235
245
|
'Installing new caniuse-lite version\n' +
|
|
236
|
-
|
|
246
|
+
pico.yellow('$ ' + install + ' caniuse-lite') +
|
|
247
|
+
'\n'
|
|
237
248
|
)
|
|
238
249
|
try {
|
|
239
250
|
childProcess.execSync(install + ' caniuse-lite')
|
|
240
251
|
} catch (e) /* istanbul ignore next */ {
|
|
241
252
|
print(
|
|
242
|
-
red(
|
|
253
|
+
pico.red(
|
|
243
254
|
'\n' +
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
255
|
+
e.stack +
|
|
256
|
+
'\n\n' +
|
|
257
|
+
'Problem with `' +
|
|
258
|
+
install +
|
|
259
|
+
' caniuse-lite` call. ' +
|
|
260
|
+
'Run it manually.\n'
|
|
247
261
|
)
|
|
248
262
|
)
|
|
249
263
|
process.exit(1)
|
|
@@ -252,7 +266,8 @@ function updatePackageManually (print, lock, latest) {
|
|
|
252
266
|
var del = lock.mode === 'yarn' ? 'yarn remove -W' : lock.mode + ' uninstall'
|
|
253
267
|
print(
|
|
254
268
|
'Cleaning package.json dependencies from caniuse-lite\n' +
|
|
255
|
-
|
|
269
|
+
pico.yellow('$ ' + del + ' caniuse-lite') +
|
|
270
|
+
'\n'
|
|
256
271
|
)
|
|
257
272
|
childProcess.execSync(del + ' caniuse-lite')
|
|
258
273
|
}
|
|
@@ -269,25 +284,27 @@ module.exports = function updateDB (print) {
|
|
|
269
284
|
browsersListRetrievalError = e
|
|
270
285
|
}
|
|
271
286
|
|
|
272
|
-
print(
|
|
273
|
-
'Latest version: ' + bold(green(latest.version)) + '\n'
|
|
274
|
-
)
|
|
287
|
+
print('Latest version: ' + pico.bold(pico.green(latest.version)) + '\n')
|
|
275
288
|
|
|
276
289
|
if (lock.mode === 'yarn' && lock.version !== 1) {
|
|
277
290
|
var update = 'yarn up -R'
|
|
278
291
|
print(
|
|
279
292
|
'Updating caniuse-lite version\n' +
|
|
280
|
-
|
|
293
|
+
pico.yellow('$ ' + update + ' caniuse-lite') +
|
|
294
|
+
'\n'
|
|
281
295
|
)
|
|
282
296
|
try {
|
|
283
297
|
childProcess.execSync(update + ' caniuse-lite')
|
|
284
298
|
} catch (e) /* istanbul ignore next */ {
|
|
285
299
|
print(
|
|
286
|
-
red(
|
|
300
|
+
pico.red(
|
|
287
301
|
'\n' +
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
302
|
+
e.stack +
|
|
303
|
+
'\n\n' +
|
|
304
|
+
'Problem with `' +
|
|
305
|
+
update +
|
|
306
|
+
' caniuse-lite` call. ' +
|
|
307
|
+
'Run it manually.\n'
|
|
291
308
|
)
|
|
292
309
|
)
|
|
293
310
|
process.exit(1)
|
|
@@ -309,11 +326,12 @@ module.exports = function updateDB (print) {
|
|
|
309
326
|
|
|
310
327
|
if (browsersListRetrievalError) {
|
|
311
328
|
print(
|
|
312
|
-
red(
|
|
329
|
+
pico.red(
|
|
313
330
|
'\n' +
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
331
|
+
browsersListRetrievalError.stack +
|
|
332
|
+
'\n\n' +
|
|
333
|
+
'Problem with browser list retrieval.\n' +
|
|
334
|
+
'Target browser changes won’t be shown.\n'
|
|
317
335
|
)
|
|
318
336
|
)
|
|
319
337
|
} else {
|
|
@@ -325,7 +343,7 @@ module.exports = function updateDB (print) {
|
|
|
325
343
|
print('\nTarget browser changes:\n')
|
|
326
344
|
print(targetBrowserChanges + '\n')
|
|
327
345
|
} else {
|
|
328
|
-
print('\n' + green('No target browser changes') + '\n')
|
|
346
|
+
print('\n' + pico.green('No target browser changes') + '\n')
|
|
329
347
|
}
|
|
330
348
|
}
|
|
331
349
|
}
|