browserslist 4.6.4 → 4.7.1

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/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.1
5
+ * Improve caching.
6
+
7
+ ## 4.7
8
+ * Add PhantomJS queries.
9
+ * Improve docs (by Dorian Koehring).
10
+
11
+ ## 4.6.6
12
+ * Remove Safari from `dead` query.
13
+
14
+ ## 4.6.5
15
+ * Add Samsung 4 browser to `dead` query.
16
+ * Remove dirty fix for `android all` error.
17
+
4
18
  ## 4.6.4
5
19
  * Add Firefox 68 to `Firefox ESR` query.
6
20
 
package/README.md CHANGED
@@ -45,7 +45,6 @@ Browserslist will take queries from tool option,
45
45
  `browserslist` config, `.browserslistrc` config,
46
46
  `browserslist` section in `package.json` or environment variables.
47
47
 
48
- You can test Browserslist queries in [online demo].
49
48
  [Browserslist Example] shows how every tool uses Browserslist.
50
49
 
51
50
  [cult-img]: https://cultofmartians.com/assets/badges/badge.svg
@@ -62,7 +61,6 @@ 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
@@ -73,16 +71,17 @@ You can test Browserslist queries in [online demo].
73
71
  2. [Best Practices](#best-practices)
74
72
  3. [Queries](#queries)
75
73
  4. [Config File](#config-file)
76
- 5. [Configuring for Different Environments](#configuring-for-different-environments)
77
- 6. [Custom Usage Data](#custom-usage-data)
78
- 7. [JS API](#js-api)
79
- 8. [Environment Variables](#environment-variables)
80
- 9. [Cache](#cache)
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)
81
80
 
82
81
  ## Tools
83
82
 
84
- * [`browserslist-ga`] downloads your website browsers statistics
85
- 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.
86
85
  * [`browserslist-useragent-regexp`] compiles Browserslist query to a RegExp
87
86
  to test browser useragent.
88
87
  * [`browserslist-useragent-ruby`] is a Ruby library to checks browser
@@ -94,12 +93,13 @@ You can test Browserslist queries in [online demo].
94
93
  target browsers. This CLI tool is built-in and available in any project
95
94
  with Autoprefixer.
96
95
 
96
+ [`browserslist-useragent-regexp`]: https://github.com/browserslist/browserslist-useragent-regexp
97
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
98
100
  [`browserslist-useragent`]: https://github.com/pastelsky/browserslist-useragent
99
- [`browserslist-useragent-regexp`]: https://github.com/browserslist/browserslist-useragent-regexp
100
101
  [`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
101
102
  [`caniuse-api`]: https://github.com/Nyalab/caniuse-api
102
- [`browserslist-browserstack`]: https://github.com/xeroxinteractive/browserslist-browserstack
103
103
 
104
104
 
105
105
  ## Best Practices
@@ -133,7 +133,7 @@ You can test Browserslist queries in [online demo].
133
133
  ## Queries
134
134
 
135
135
  Browserslist will use browsers and Node.js versions query
136
- from one of this sources:
136
+ from one of these sources:
137
137
 
138
138
  1. `browserslist` key in `package.json` file in current or parent directories.
139
139
  **We recommend this way.**
@@ -194,16 +194,17 @@ You can specify the browser and Node.js versions by queries (case insensitive):
194
194
  `>=`, `<` and `<=` work too. It also works with Node.js.
195
195
  * `iOS 7`: the iOS browser version 7 directly.
196
196
  * `Firefox ESR`: the latest [Firefox ESR] version.
197
+ * `PhantomJS 2.1` and `PhantomJS 1.9`: selects Safari versions similar
198
+ to PhantomJS runtime.
197
199
  * `unreleased versions` or `unreleased Chrome versions`:
198
200
  alpha and beta versions.
199
201
  * `last 2 major versions` or `last 2 iOS major versions`:
200
202
  all minor/patch releases of last 2 major versions.
201
203
  * `since 2015` or `last 2 years`: all versions released since year 2015
202
204
  (also `since 2015-03` and `since 2015-03-10`).
203
- * `dead`: browsers from `last 2 version` query, but with less than 0.5%
204
- in global usage statistics and without official support or updates
205
- for 24 months. Right now it is `IE 10`, `IE_Mob 10`, `BlackBerry 10`,
206
- `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`.
207
208
  * `last 2 versions`: the last 2 versions for *each* browser.
208
209
  * `last 2 Chrome versions`: the last 2 versions of Chrome browser.
209
210
  * `defaults`: Browserslist’s default browsers
@@ -408,8 +409,10 @@ If you have a website, you can query against the usage statistics of your site.
408
409
  npx browserslist-ga
409
410
  ```
410
411
 
411
- Of course, you can generate usage statistics file by any other method.
412
- 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:
413
416
 
414
417
  ```js
415
418
  {
@@ -425,12 +428,13 @@ File format should be like:
425
428
  }
426
429
  ```
427
430
 
428
- Note that you can query against your custom usage data
429
- while also querying against global or regional data.
430
- 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.
431
434
 
432
- [`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
433
- [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/
434
438
 
435
439
 
436
440
  ## JS API
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
@@ -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,15 +940,6 @@ 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) {
@@ -973,8 +947,6 @@ var QUERIES = [
973
947
  'ie <= 10', 'ie_mob <= 10',
974
948
  'bb <= 10',
975
949
  'op_mob <= 12.1',
976
- 'safari <= 11',
977
- 'ios_saf <= 11',
978
950
  'samsung 4'
979
951
  ]
980
952
  return resolve(dead, context)
package/node.js CHANGED
@@ -42,7 +42,8 @@ function isFile (file) {
42
42
  }
43
43
 
44
44
  function eachParent (file, callback) {
45
- var loc = path.resolve(file)
45
+ var dir = isFile(file) ? path.dirname(file) : file
46
+ var loc = path.resolve(dir)
46
47
  do {
47
48
  var result = callback(loc)
48
49
  if (typeof result !== 'undefined') return result
@@ -243,7 +244,10 @@ module.exports = {
243
244
  return configCache[cacheKey]
244
245
  }
245
246
 
247
+ var passed = []
246
248
  var resolved = eachParent(from, function (dir) {
249
+ passed.push(dir)
250
+
247
251
  var config = path.join(dir, 'browserslist')
248
252
  var pkg = path.join(dir, 'package.json')
249
253
  var rc = path.join(dir, '.browserslistrc')
@@ -277,7 +281,9 @@ module.exports = {
277
281
  }
278
282
  })
279
283
  if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
280
- configCache[cacheKey] = resolved
284
+ passed.forEach(function (dir) {
285
+ configCache[dir] = resolved
286
+ })
281
287
  }
282
288
  return resolved
283
289
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserslist",
3
- "version": "4.6.4",
3
+ "version": "4.7.1",
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,20 @@
11
11
  "license": "MIT",
12
12
  "repository": "browserslist/browserslist",
13
13
  "dependencies": {
14
- "caniuse-lite": "^1.0.30000981",
15
- "electron-to-chromium": "^1.3.188",
16
- "node-releases": "^1.1.25"
14
+ "caniuse-lite": "^1.0.30000999",
15
+ "electron-to-chromium": "^1.3.284",
16
+ "node-releases": "^1.1.36"
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
+ "config": "@logux/sharec-config",
28
+ "version": "0.5.4"
22
29
  }
23
30
  }