browserslist 4.6.3 → 4.7.0

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +84 -69
  3. package/index.js +19 -40
  4. package/package.json +10 -4
package/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 4.7
5
+ * Add PhantomJS queries.
6
+ * Improve docs (by Dorian Koehring).
7
+
8
+ ## 4.6.6
9
+ * Remove Safari from `dead` query.
10
+
11
+ ## 4.6.5
12
+ * Add Samsung 4 browser to `dead` query.
13
+ * Remove dirty fix for `android all` error.
14
+
15
+ ## 4.6.4
16
+ * Add Firefox 68 to `Firefox ESR` query.
17
+
4
18
  ## 4.6.3
5
19
  * Dirty fix for `android all` error.
6
20
 
package/README.md CHANGED
@@ -14,7 +14,6 @@ front-end tools. It is used in:
14
14
  * [postcss-normalize]
15
15
  * [obsolete-webpack-plugin]
16
16
 
17
- [Browserslist Example] shows how every tool uses Browserslist.
18
17
  All tools will find target browsers automatically,
19
18
  when you add the following to `package.json`:
20
19
 
@@ -46,7 +45,7 @@ Browserslist will take queries from tool option,
46
45
  `browserslist` config, `.browserslistrc` config,
47
46
  `browserslist` section in `package.json` or environment variables.
48
47
 
49
- You can test Browserslist queries in [online demo].
48
+ [Browserslist Example] shows how every tool uses Browserslist.
50
49
 
51
50
  [cult-img]: https://cultofmartians.com/assets/badges/badge.svg
52
51
  [cult]: https://cultofmartians.com/done.html
@@ -62,15 +61,27 @@ You can test Browserslist queries in [online demo].
62
61
  [postcss-preset-env]: https://github.com/jonathantneal/postcss-preset-env
63
62
  [postcss-normalize]: https://github.com/jonathantneal/postcss-normalize
64
63
  [Autoprefixer]: https://github.com/postcss/autoprefixer
65
- [online demo]: https://browserl.ist/
66
64
  [Can I Use]: https://caniuse.com/
67
65
  [Babel]: https://github.com/babel/babel/tree/master/packages/babel-preset-env
68
66
  [obsolete-webpack-plugin]: https://github.com/ElemeFE/obsolete-webpack-plugin
69
67
 
68
+ ## Table of Contents
69
+
70
+ 1. [Tools](#tools)
71
+ 2. [Best Practices](#best-practices)
72
+ 3. [Queries](#queries)
73
+ 4. [Config File](#config-file)
74
+ 5. [Shareable Configs](#shareable-configs)
75
+ 6. [Configuring for Different Environments](#configuring-for-different-environments)
76
+ 7. [Custom Usage Data](#custom-usage-data)
77
+ 8. [JS API](#js-api)
78
+ 9. [Environment Variables](#environment-variables)
79
+ 10. [Cache](#cache)
80
+
70
81
  ## Tools
71
82
 
72
- * [`browserslist-ga`] downloads your website browsers statistics
73
- to use it in `> 0.5% in my stats` query.
83
+ * [`browserslist-ga`] and [`browserslist-ga-export`] download your website
84
+ browsers statistics to use it in `> 0.5% in my stats` query.
74
85
  * [`browserslist-useragent-regexp`] compiles Browserslist query to a RegExp
75
86
  to test browser useragent.
76
87
  * [`browserslist-useragent-ruby`] is a Ruby library to checks browser
@@ -82,12 +93,13 @@ You can test Browserslist queries in [online demo].
82
93
  target browsers. This CLI tool is built-in and available in any project
83
94
  with Autoprefixer.
84
95
 
96
+ [`browserslist-useragent-regexp`]: https://github.com/browserslist/browserslist-useragent-regexp
85
97
  [`browserslist-useragent-ruby`]: https://github.com/browserslist/browserslist-useragent-ruby
98
+ [`browserslist-browserstack`]: https://github.com/xeroxinteractive/browserslist-browserstack
99
+ [`browserslist-ga-export`]: https://github.com/browserslist/browserslist-ga-export
86
100
  [`browserslist-useragent`]: https://github.com/pastelsky/browserslist-useragent
87
- [`browserslist-useragent-regexp`]: https://github.com/browserslist/browserslist-useragent-regexp
88
101
  [`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
89
102
  [`caniuse-api`]: https://github.com/Nyalab/caniuse-api
90
- [`browserslist-browserstack`]: https://github.com/xeroxinteractive/browserslist-browserstack
91
103
 
92
104
 
93
105
  ## Best Practices
@@ -121,7 +133,7 @@ You can test Browserslist queries in [online demo].
121
133
  ## Queries
122
134
 
123
135
  Browserslist will use browsers and Node.js versions query
124
- from one of this sources:
136
+ from one of these sources:
125
137
 
126
138
  1. `browserslist` key in `package.json` file in current or parent directories.
127
139
  **We recommend this way.**
@@ -144,14 +156,14 @@ intersection of the previous query: `last 1 version and > 1%`.
144
156
  There is 3 different ways to combine queries as depicted below. First you start
145
157
  with a single query and then we combine the queries to get our final list.
146
158
 
147
- Obviously you can *not* start with a `not` combiner, since the is no left-hand
159
+ Obviously you can *not* start with a `not` combiner, since there is no left-hand
148
160
  side query to combine it with.
149
161
 
150
162
  | Query combiner type | Illustration | Example |
151
163
  | ------------------- | :----------: | ------- |
152
- |`or`/ `,` combiner <br> (union) | ![Union of queries](img/union.svg) | `'> .5% or last 2 versions'` <br> `'> .5%, last 2 versions'` |
153
- | `and` combiner <br> (intersection) | ![intersection of queries](img/intersection.svg) | `'> .5% and last 2 versions'` |
154
- | `not` combiner <br> (relative complement) | ![Relative complement of queries](img/complement.svg) | `'> .5% and not last 2 versions'` <br> `'> .5% or not last 2 versions'` <br> `'> .5%, not last 2 versions'` |
164
+ |`or`/`,` combiner <br> (union) | ![Union of queries](img/union.svg) | `> .5% or last 2 versions` <br> `> .5%, last 2 versions` |
165
+ | `and` combiner <br> (intersection) | ![intersection of queries](img/intersection.svg) | `> .5% and last 2 versions` |
166
+ | `not` combiner <br> (relative complement) | ![Relative complement of queries](img/complement.svg) | `> .5% and not last 2 versions` <br> `> .5% or not last 2 versions` <br> `> .5%, not last 2 versions` |
155
167
 
156
168
  _A quick way to test your query is to do `npx browserslist '> 0.5%, not IE 11'`
157
169
  in your terminal._
@@ -182,16 +194,17 @@ You can specify the browser and Node.js versions by queries (case insensitive):
182
194
  `>=`, `<` and `<=` work too. It also works with Node.js.
183
195
  * `iOS 7`: the iOS browser version 7 directly.
184
196
  * `Firefox ESR`: the latest [Firefox ESR] version.
197
+ * `PhantomJS 2.1` and `PhantomJS 1.9`: selects Safari versions similar
198
+ to PhantomJS runtime.
185
199
  * `unreleased versions` or `unreleased Chrome versions`:
186
200
  alpha and beta versions.
187
201
  * `last 2 major versions` or `last 2 iOS major versions`:
188
202
  all minor/patch releases of last 2 major versions.
189
203
  * `since 2015` or `last 2 years`: all versions released since year 2015
190
204
  (also `since 2015-03` and `since 2015-03-10`).
191
- * `dead`: browsers from `last 2 version` query, but with less than 0.5%
192
- in global usage statistics and without official support or updates
193
- for 24 months. Right now it is `IE 10`, `IE_Mob 10`, `BlackBerry 10`,
194
- `BlackBerry 7`, and `OperaMobile 12.1`.
205
+ * `dead`: browsers without official support or updates for 24 months.
206
+ Right now it is `IE 10`, `IE_Mob 10`, `BlackBerry 10`, `BlackBerry 7`,
207
+ `Samsung 4` and `OperaMobile 12.1`.
195
208
  * `last 2 versions`: the last 2 versions for *each* browser.
196
209
  * `last 2 Chrome versions`: the last 2 versions of Chrome browser.
197
210
  * `defaults`: Browserslist’s default browsers
@@ -258,7 +271,9 @@ Names are case insensitive:
258
271
  * `kaios` for KaiOS Browser.
259
272
 
260
273
 
261
- ## `package.json`
274
+ ## Config File
275
+
276
+ ### `package.json`
262
277
 
263
278
  If you want to reduce config files in project root, you can specify
264
279
  browsers in `package.json` with `browserslist` key:
@@ -278,9 +293,9 @@ browsers in `package.json` with `browserslist` key:
278
293
  ```
279
294
 
280
295
 
281
- ## Config File
296
+ ### `.browserslistrc`
282
297
 
283
- Browserslist config should be named `.browserslistrc` or `browserslist`
298
+ Separated Browserslist config should be named `.browserslistrc`
284
299
  and have browsers queries split by a new line. Comments starts with `#` symbol:
285
300
 
286
301
  ```yaml
@@ -343,46 +358,7 @@ module.exports = [
343
358
  ```
344
359
 
345
360
 
346
- ## Environment Variables
347
-
348
- If some tool use Browserslist inside, you can change browsers settings
349
- by [environment variables]:
350
-
351
- * `BROWSERSLIST` with browsers queries.
352
-
353
- ```sh
354
- BROWSERSLIST="> 5%" gulp css
355
- ```
356
-
357
- * `BROWSERSLIST_CONFIG` with path to config file.
358
-
359
- ```sh
360
- BROWSERSLIST_CONFIG=./config/browserslist gulp css
361
- ```
362
-
363
- * `BROWSERSLIST_ENV` with environments string.
364
-
365
- ```sh
366
- BROWSERSLIST_ENV="development" gulp css
367
- ```
368
-
369
- * `BROWSERSLIST_STATS` with path to the custom usage data
370
- for `> 1% in my stats` query.
371
-
372
- ```sh
373
- BROWSERSLIST_STATS=./config/usage_data.json gulp css
374
- ```
375
-
376
- * `BROWSERSLIST_DISABLE_CACHE` if you want to disable config reading cache.
377
-
378
- ```sh
379
- BROWSERSLIST_DISABLE_CACHE=1 gulp css
380
- ```
381
-
382
- [environment variables]: https://en.wikipedia.org/wiki/Environment_variable
383
-
384
-
385
- ## Environments
361
+ ## Configuring for Different Environments
386
362
 
387
363
  You can also specify different browser queries for various environments.
388
364
  Browserslist will choose query according to `BROWSERSLIST_ENV` or `NODE_ENV`
@@ -433,8 +409,10 @@ If you have a website, you can query against the usage statistics of your site.
433
409
  npx browserslist-ga
434
410
  ```
435
411
 
436
- Of course, you can generate usage statistics file by any other method.
437
- File format should be like:
412
+ Or you can use [`browserslist-ga-export`] to convert Google Analytics data without giving a password for Google account.
413
+
414
+ You can generate usage statistics file by any other method. File format should
415
+ be like:
438
416
 
439
417
  ```js
440
418
  {
@@ -450,12 +428,13 @@ File format should be like:
450
428
  }
451
429
  ```
452
430
 
453
- Note that you can query against your custom usage data
454
- while also querying against global or regional data.
455
- For example, the query `> 1% in my stats, > 5% in US, 10%` is permitted.
431
+ Note that you can query against your custom usage data while also querying
432
+ against global or regional data. For example, the query
433
+ `> 1% in my stats, > 5% in US, 10%` is permitted.
456
434
 
457
- [`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
458
- [Can I Use]: https://caniuse.com/
435
+ [`browserslist-ga-export`]: https://github.com/browserslist/browserslist-ga-export
436
+ [`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
437
+ [Can I Use]: https://caniuse.com/
459
438
 
460
439
 
461
440
  ## JS API
@@ -502,9 +481,6 @@ For non-JS environment and debug purpose you can use CLI tool:
502
481
  browserslist "> 1%, IE 10"
503
482
  ```
504
483
 
505
-
506
- ## Coverage
507
-
508
484
  You can get total users coverage for selected browsers by JS API:
509
485
 
510
486
  ```js
@@ -550,6 +526,45 @@ These browsers account for 83.1% of all users in custom statistics
550
526
  ```
551
527
 
552
528
 
529
+ ## Environment Variables
530
+
531
+ If some tool use Browserslist inside, you can change browsers settings
532
+ by [environment variables]:
533
+
534
+ * `BROWSERSLIST` with browsers queries.
535
+
536
+ ```sh
537
+ BROWSERSLIST="> 5%" gulp css
538
+ ```
539
+
540
+ * `BROWSERSLIST_CONFIG` with path to config file.
541
+
542
+ ```sh
543
+ BROWSERSLIST_CONFIG=./config/browserslist gulp css
544
+ ```
545
+
546
+ * `BROWSERSLIST_ENV` with environments string.
547
+
548
+ ```sh
549
+ BROWSERSLIST_ENV="development" gulp css
550
+ ```
551
+
552
+ * `BROWSERSLIST_STATS` with path to the custom usage data
553
+ for `> 1% in my stats` query.
554
+
555
+ ```sh
556
+ BROWSERSLIST_STATS=./config/usage_data.json gulp css
557
+ ```
558
+
559
+ * `BROWSERSLIST_DISABLE_CACHE` if you want to disable config reading cache.
560
+
561
+ ```sh
562
+ BROWSERSLIST_DISABLE_CACHE=1 gulp css
563
+ ```
564
+
565
+ [environment variables]: https://en.wikipedia.org/wiki/Environment_variable
566
+
567
+
553
568
  ## Cache
554
569
 
555
570
  Browserslist caches the configuration it reads from `package.json` and
package/index.js CHANGED
@@ -10,10 +10,7 @@ var env = require('./node') // Will load browser.js in webpack
10
10
  var FLOAT_RANGE = /^\d+(\.\d+)?(-\d+(\.\d+)?)*$/
11
11
  var YEAR = 365.259641 * 24 * 60 * 60 * 1000
12
12
 
13
- // Enum values MUST be powers of 2, so combination are safe
14
- /** @constant {number} */
15
13
  var QUERY_OR = 1
16
- /** @constant {number} */
17
14
  var QUERY_AND = 2
18
15
 
19
16
  function isVersionsMatch (versionA, versionB) {
@@ -265,14 +262,10 @@ function resolve (queries, context) {
265
262
  case QUERY_AND:
266
263
  if (isExclude) {
267
264
  return result.filter(function (j) {
268
- // remove result items that are in array
269
- // (the relative complement of array in result)
270
265
  return array.indexOf(j) === -1
271
266
  })
272
267
  } else {
273
268
  return result.filter(function (j) {
274
- // remove result items not in array
275
- // (intersect of result and array)
276
269
  return array.indexOf(j) !== -1
277
270
  })
278
271
  }
@@ -287,7 +280,6 @@ function resolve (queries, context) {
287
280
  return !filter[j]
288
281
  })
289
282
  }
290
- // union of result and array
291
283
  return result.concat(array)
292
284
  }
293
285
  }
@@ -375,35 +367,14 @@ function browserslist (queries, opts) {
375
367
  return uniq(result)
376
368
  }
377
369
 
378
- /**
379
- * @typedef {object} BrowserslistQuery
380
- * @property {number} type A type constant like QUERY_OR @see QUERY_OR.
381
- * @property {string} queryString A query like "not ie < 11".
382
- */
383
-
384
- /**
385
- * Parse a browserslist string query
386
- * @param {string} queries One or more queries as a string
387
- * @returns {BrowserslistQuery[]} An array of BrowserslistQuery
388
- */
389
370
  function parse (queries) {
390
371
  var qs = []
391
-
392
372
  do {
393
373
  queries = doMatch(queries, qs)
394
374
  } while (queries)
395
-
396
375
  return qs
397
376
  }
398
377
 
399
- /**
400
- * Find query matches in a string. This function is meant to be called
401
- * repeatedly with the returned query string until there is no more matches.
402
- * @param {string} string A string with one or more queries.
403
- * @param {BrowserslistQuery[]} qs Out parameter,
404
- * will be filled with `BrowserslistQuery`.
405
- * @returns {string} The rest of the query string minus the matched part.
406
- */
407
378
  function doMatch (string, qs) {
408
379
  var or = /^(?:,\s*|\s+OR\s+)(.*)/i
409
380
  var and = /^\s+AND\s+(.*)/i
@@ -857,7 +828,7 @@ var QUERIES = [
857
828
  {
858
829
  regexp: /^(firefox|ff|fx)\s+esr$/i,
859
830
  select: function () {
860
- return ['firefox 60']
831
+ return ['firefox 68', 'firefox 60']
861
832
  }
862
833
  },
863
834
  {
@@ -918,6 +889,18 @@ var QUERIES = [
918
889
  return resolve(queries, context)
919
890
  }
920
891
  },
892
+ {
893
+ regexp: /^phantomjs\s+1.9$/i,
894
+ select: function () {
895
+ return ['safari 5']
896
+ }
897
+ },
898
+ {
899
+ regexp: /^phantomjs\s+2.1$/i,
900
+ select: function () {
901
+ return ['safari 6']
902
+ }
903
+ },
921
904
  {
922
905
  regexp: /^(\w+)\s+(tp|[\d.]+)$/i,
923
906
  select: function (context, name, version) {
@@ -957,19 +940,15 @@ var QUERIES = [
957
940
  return browserslist(browserslist.defaults)
958
941
  }
959
942
  },
960
- {
961
- regexp: /^android all$/i,
962
- select: function () {
963
- /* istanbul ignore next */
964
- console.warn('BrowserslistError: Unknown browser query `android all`')
965
- /* istanbul ignore next */
966
- return []
967
- }
968
- },
969
943
  {
970
944
  regexp: /^dead$/i,
971
945
  select: function (context) {
972
- var dead = ['ie <= 10', 'ie_mob <= 10', 'bb <= 10', 'op_mob <= 12.1']
946
+ var dead = [
947
+ 'ie <= 10', 'ie_mob <= 10',
948
+ 'bb <= 10',
949
+ 'op_mob <= 12.1',
950
+ 'samsung 4'
951
+ ]
973
952
  return resolve(dead, context)
974
953
  }
975
954
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserslist",
3
- "version": "4.6.3",
3
+ "version": "4.7.0",
4
4
  "description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
5
5
  "keywords": [
6
6
  "caniuse",
@@ -11,13 +11,19 @@
11
11
  "license": "MIT",
12
12
  "repository": "browserslist/browserslist",
13
13
  "dependencies": {
14
- "caniuse-lite": "^1.0.30000975",
15
- "electron-to-chromium": "^1.3.164",
16
- "node-releases": "^1.1.23"
14
+ "caniuse-lite": "^1.0.30000989",
15
+ "electron-to-chromium": "^1.3.247",
16
+ "node-releases": "^1.1.29"
17
17
  },
18
18
  "bin": "./cli.js",
19
19
  "browser": {
20
20
  "./node.js": "./browser.js",
21
21
  "path": false
22
+ },
23
+ "eslintIgnore": [
24
+ "test/fixtures"
25
+ ],
26
+ "sharec": {
27
+ "version": "0.4.2"
22
28
  }
23
29
  }