browserslist 2.9.1 → 2.11.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 +12 -0
  2. package/README.md +24 -23
  3. package/index.js +50 -12
  4. package/package.json +12 -10
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 2.11
5
+ * Add `last 2 years` query support (by James Harris).
6
+
7
+ ## 2.10.2
8
+ * Fix Browserify support.
9
+
10
+ ## 2.10.1
11
+ * Fix using Browserslist without `process` (by Andrew Patton).
12
+
13
+ ## 2.10
14
+ * Add `< 1%` and `<= 1%` queries support (by August Kaiser).
15
+
4
16
  ## 2.9.1
5
17
  * Fix unknown query on trailing spaces in query.
6
18
 
package/README.md CHANGED
@@ -8,7 +8,8 @@ It is used in:
8
8
 
9
9
  * [Autoprefixer]
10
10
  * [babel-preset-env]
11
- (external config in `package.json` or `browserslist` files supported in 2.0)
11
+ (external config in `package.json` or `browserslist` will be supported in 7.0)
12
+ * [postcss-preset-env]
12
13
  * [eslint-plugin-compat]
13
14
  * [stylelint-no-unsupported-browser-features]
14
15
  * [postcss-normalize]
@@ -55,7 +56,8 @@ You can test Browserslist queries in [online demo].
55
56
 
56
57
  [stylelint-no-unsupported-browser-features]: https://github.com/ismay/stylelint-no-unsupported-browser-features
57
58
  [eslint-plugin-compat]: https://github.com/amilajack/eslint-plugin-compat
58
- [babel-preset-env]: https://github.com/babel/babel-preset-env
59
+ [postcss-preset-env]: https://github.com/jonathantneal/postcss-preset-env
60
+ [babel-preset-env]: https://github.com/babel/babel/tree/master/packages/babel-preset-env
59
61
  [postcss-normalize]: https://github.com/jonathantneal/postcss-normalize
60
62
  [Autoprefixer]: https://github.com/postcss/autoprefixer
61
63
  [online demo]: http://browserl.ist/
@@ -63,13 +65,15 @@ You can test Browserslist queries in [online demo].
63
65
 
64
66
  ## Tools
65
67
 
66
- * [browserslist-useragent] check browser by user agent string
68
+ * [`browserslist-useragent`] checks browser by user agent string
67
69
  to match Browserslist target browsers query.
70
+ * [`caniuse-api`] returns browsers which support some specific feature.
68
71
  * Run `npx browserslist` in your project directory to see project’s
69
- target browsers. This CLI tool is built-in and available in any project
72
+ target browsers. This CLI tool is built-in and available in any project
70
73
  with Autoprefixer.
71
74
 
72
- [browserslist-useragent]: https://github.com/pastelsky/browserslist-useragent
75
+ [`browserslist-useragent`]: https://github.com/pastelsky/browserslist-useragent
76
+ [`caniuse-api`]: https://github.com/Nyalab/caniuse-api
73
77
 
74
78
  ## Queries
75
79
 
@@ -88,29 +92,26 @@ You can specify the versions by queries (case insensitive):
88
92
 
89
93
  * `last 2 versions`: the last 2 versions for each browser.
90
94
  * `last 2 Chrome versions`: the last 2 versions of Chrome browser.
91
- * `last 2 major versions`: all minor/patch releases of the current
92
- and previous major versions.
93
- * `last 2 iOS major versions`: all minor/patch releases of the current
94
- and previous major versions of iOS Safari.
95
- * `> 5%` or `>= 5%`: versions selected by global usage statistics.
95
+ * `> 5%`: versions selected by global usage statistics.
96
+ `>=`, `<` and `<=` work too.
96
97
  * `> 5% in US`: uses USA usage statistics. It accepts [two-letter country code].
97
98
  * `> 5% in alt-AS`: uses Asia region usage statistics. List of all region codes
98
99
  can be found at [`caniuse-lite/data/regions`].
99
100
  * `> 5% in my stats`: uses [custom usage data].
101
+ * `extends browserslist-config-mycompany`: take queries from
102
+ `browserslist-config-mycompany` npm package.
100
103
  * `ie 6-8`: selects an inclusive range of versions.
101
104
  * `Firefox > 20`: versions of Firefox newer than 20.
102
- * `Firefox >= 20`: versions of Firefox newer than or equal to 20.
103
- * `Firefox < 20`: versions of Firefox less than 20.
104
- * `Firefox <= 20`: versions of Firefox less than or equal to 20.
105
- * `Firefox ESR`: the latest [Firefox ESR] version.
105
+ `>=`, `<` and `<=` work too.
106
106
  * `iOS 7`: the iOS browser version 7 directly.
107
- * `extends browserslist-config-mycompany`: take queries from
108
- `browserslist-config-mycompany` npm package.
109
- * `unreleased versions`: alpha and beta versions of each browser.
110
- * `unreleased Chrome versions`: alpha and beta versions of Chrome browser.
111
- * `not ie <= 8`: exclude browsers selected before by previous queries.
112
- * `since 2013`: all versions released since year 2013
113
- (also `since 2013-03` and `since 2013-03-10`).
107
+ * `Firefox ESR`: the latest [Firefox ESR] version.
108
+ * `unreleased versions` or `unreleased Chrome versions`:
109
+ alpha and beta versions.
110
+ * `last 2 major versions` or `last 2 iOS major versions`:
111
+ all minor/patch releases of last 2 major versions.
112
+ * `since 2015` or `last 2 years`: all versions released since year 2015
113
+ (also `since 2015-03` and `since 2015-03-10`).
114
+ * `not ie <= 8`: exclude browsers selected by previous queries.
114
115
 
115
116
  You can add `not ` to any query.
116
117
 
@@ -368,10 +369,10 @@ For example, the query `> 1% in my stats, > 5% in US, 10%` is permitted.
368
369
  ## Webpack
369
370
 
370
371
  If you plan to use Browserslist on client-side (e. g., tools like CodePen)
371
- Browserslist could take big part of your bundle about 150 KB.
372
+ Browserslist could take big part of your bundle (150 KB).
372
373
 
373
374
  But the biggest part of this size will be region usage statistics, which could
374
- be useless for you. You can use `IgnorePlugin` in webpack to cut it:
375
+ be useless for you. `IgnorePlugin` could cut it:
375
376
 
376
377
  ```js
377
378
  const webpackConfig = {
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ var process = require('process')
1
2
  var path = require('path')
2
3
  var e2c = require('electron-to-chromium/versions')
3
4
  var fs = require('fs')
@@ -32,7 +33,7 @@ function getMajorVersions (released, number) {
32
33
  return selected
33
34
  }
34
35
 
35
- var env = process.env
36
+ var env = process && process.env ? process.env : { }
36
37
 
37
38
  var FLOAT_RANGE = /^\d+(\.\d+)?(-\d+(\.\d+)?)*$/
38
39
  var IS_SECTION = /^\s*\[(.+)\]\s*$/
@@ -321,6 +322,17 @@ function loadCountryStatistics (country) {
321
322
  }
322
323
  }
323
324
 
325
+ function filterByYear (since) {
326
+ return Object.keys(agents).reduce(function (selected, name) {
327
+ var data = byName(name)
328
+ if (!data) return selected
329
+ var versions = Object.keys(data.releaseDate).filter(function (v) {
330
+ return data.releaseDate[v] >= since
331
+ })
332
+ return selected.concat(versions.map(nameMapper(data.name)))
333
+ }, [])
334
+ }
335
+
324
336
  // Will be filled by Can I Use data below
325
337
  browserslist.data = { }
326
338
  browserslist.usage = {
@@ -579,6 +591,15 @@ var QUERIES = [
579
591
  }).map(nameMapper(data.name))
580
592
  }
581
593
  },
594
+ {
595
+ regexp: /^last\s+(\d+)\s+years?$/i,
596
+ select: function (context, years) {
597
+ var date = new Date()
598
+ var since = date.setFullYear(date.getFullYear() - years) / 1000
599
+
600
+ return filterByYear(since)
601
+ }
602
+ },
582
603
  {
583
604
  regexp: /^since (\d+)(?:-(\d+))?(?:-(\d+))?$/i,
584
605
  select: function (context, year, month, date) {
@@ -587,18 +608,11 @@ var QUERIES = [
587
608
  date = parseInt(date || '01')
588
609
  var since = Date.UTC(year, month, date, 0, 0, 0) / 1000
589
610
 
590
- return Object.keys(agents).reduce(function (selected, name) {
591
- var data = byName(name)
592
- if (!data) return selected
593
- var versions = Object.keys(data.releaseDate).filter(function (v) {
594
- return data.releaseDate[v] >= since
595
- })
596
- return selected.concat(versions.map(nameMapper(data.name)))
597
- }, [])
611
+ return filterByYear(since)
598
612
  }
599
613
  },
600
614
  {
601
- regexp: /^(>=?)\s*(\d*\.?\d+)%$/,
615
+ regexp: /^(>=?|<=?)\s*(\d*\.?\d+)%$/,
602
616
  select: function (context, sign, popularity) {
603
617
  popularity = parseFloat(popularity)
604
618
  var usage = browserslist.usage.global
@@ -608,6 +622,14 @@ var QUERIES = [
608
622
  if (usage[version] > popularity) {
609
623
  result.push(version)
610
624
  }
625
+ } else if (sign === '<') {
626
+ if (usage[version] < popularity) {
627
+ result.push(version)
628
+ }
629
+ } else if (sign === '<=') {
630
+ if (usage[version] <= popularity) {
631
+ result.push(version)
632
+ }
611
633
  } else if (usage[version] >= popularity) {
612
634
  result.push(version)
613
635
  }
@@ -616,7 +638,7 @@ var QUERIES = [
616
638
  }
617
639
  },
618
640
  {
619
- regexp: /^(>=?)\s*(\d*\.?\d+)%\s+in\s+my\s+stats$/,
641
+ regexp: /^(>=?|<=?)\s*(\d*\.?\d+)%\s+in\s+my\s+stats$/,
620
642
  select: function (context, sign, popularity) {
621
643
  popularity = parseFloat(popularity)
622
644
 
@@ -631,6 +653,14 @@ var QUERIES = [
631
653
  if (usage[version] > popularity) {
632
654
  result.push(version)
633
655
  }
656
+ } else if (sign === '<') {
657
+ if (usage[version] < popularity) {
658
+ result.push(version)
659
+ }
660
+ } else if (sign === '<=') {
661
+ if (usage[version] <= popularity) {
662
+ result.push(version)
663
+ }
634
664
  } else if (usage[version] >= popularity) {
635
665
  result.push(version)
636
666
  }
@@ -639,7 +669,7 @@ var QUERIES = [
639
669
  }
640
670
  },
641
671
  {
642
- regexp: /^(>=?)\s*(\d*\.?\d+)%\s+in\s+((alt-)?\w\w)$/,
672
+ regexp: /^(>=?|<=?)\s*(\d*\.?\d+)%\s+in\s+((alt-)?\w\w)$/,
643
673
  select: function (context, sign, popularity, place) {
644
674
  popularity = parseFloat(popularity)
645
675
 
@@ -657,6 +687,14 @@ var QUERIES = [
657
687
  if (usage[version] > popularity) {
658
688
  result.push(version)
659
689
  }
690
+ } else if (sign === '<') {
691
+ if (usage[version] < popularity) {
692
+ result.push(version)
693
+ }
694
+ } else if (sign === '<=') {
695
+ if (usage[version] <= popularity) {
696
+ result.push(version)
697
+ }
660
698
  } else if (usage[version] >= popularity) {
661
699
  result.push(version)
662
700
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browserslist",
3
- "version": "2.9.1",
3
+ "version": "2.11.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,25 +11,25 @@
11
11
  "license": "MIT",
12
12
  "repository": "ai/browserslist",
13
13
  "dependencies": {
14
- "caniuse-lite": "^1.0.30000770",
15
- "electron-to-chromium": "^1.3.27"
14
+ "caniuse-lite": "^1.0.30000784",
15
+ "electron-to-chromium": "^1.3.30"
16
16
  },
17
17
  "bin": "./cli.js",
18
18
  "devDependencies": {
19
19
  "cross-spawn": "^5.1.0",
20
- "eslint": "^4.11.0",
20
+ "eslint": "^4.14.0",
21
21
  "eslint-ci": "^0.1.1",
22
22
  "eslint-config-logux": "^17.0.0",
23
23
  "eslint-config-standard": "^10.2.1",
24
- "eslint-plugin-es5": "^1.1.0",
24
+ "eslint-plugin-es5": "^1.2.0",
25
25
  "eslint-plugin-import": "^2.8.0",
26
- "eslint-plugin-jest": "^21.3.2",
26
+ "eslint-plugin-jest": "^21.5.0",
27
27
  "eslint-plugin-node": "^5.2.1",
28
28
  "eslint-plugin-promise": "^3.6.0",
29
29
  "eslint-plugin-security": "^1.4.0",
30
30
  "eslint-plugin-standard": "^3.0.1",
31
- "jest": "^21.2.1",
32
- "lint-staged": "^5.0.0",
31
+ "jest": "^22.0.4",
32
+ "lint-staged": "^6.0.0",
33
33
  "pre-commit": "^1.1.3",
34
34
  "size-limit": "^0.13.2",
35
35
  "yaspeller-ci": "^1.0.0"
@@ -50,19 +50,20 @@
50
50
  }
51
51
  },
52
52
  "jest": {
53
+ "testEnvironment": "node",
53
54
  "coverageThreshold": {
54
55
  "global": {
55
56
  "statements": 100
56
57
  }
57
58
  },
58
59
  "modulePathIgnorePatterns": [
59
- "test/fixtures"
60
+ "<rootDir>/test/fixtures"
60
61
  ]
61
62
  },
62
63
  "size-limit": [
63
64
  {
64
65
  "path": "index.js",
65
- "limit": "155 KB"
66
+ "limit": "160 KB"
66
67
  }
67
68
  ],
68
69
  "scripts": {
@@ -76,6 +77,7 @@
76
77
  "*.js": "eslint"
77
78
  },
78
79
  "browser": {
80
+ "process": false,
79
81
  "path": false,
80
82
  "fs": false
81
83
  },