Initial commit

This commit is contained in:
Developer
2025-04-21 16:03:20 +02:00
commit 2832896157
22874 changed files with 3092801 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale Issue or Pull Request is closed
daysUntilClose: 7
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- has pr
- pinned
- security
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as `stale` because it has not had
recent activity 😴. It will be closed if no further activity occurs. Thank you
for your contributions 👌!
# Comment to post when removing the stale label. Set to `false` to disable
unmarkComment: false
# Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable
closeComment: false
# Limit to only `issues` or `pulls`
# only: issues

View File

@@ -0,0 +1,668 @@
# Changelog
## v1.6.1 (2017-10-17)
### :bug: Bug Fix
- Update compat table to fix two small issues ([#445](https://github.com/babel/babel-preset-env/pull/445)) (@danez)
ES2015 destructuring is not fully supported in Edge 15 and the polyfill required again. `es6.math.imul` is supported on Android as of version 4.4
- Add polyfills for ES6 static Object methods ([#441](https://github.com/babel/babel-preset-env/pull/441)) (@danez)
Functions such as `Object.keys`, `Object.freeze`, ... do already exist in ES5, but their behaviour changed in ES2015. `babel-preset-env` with `builtIns: true` now adds the core-js polyfills for this methods if the browser only supports the ES5 variant of the method (like IE11 for example)
- Normalize module format of plugins/built-ins data ([#376](https://github.com/babel/babel-preset-env/pull/376)) (@rtsao)
## v1.6.0 (2017-07-04)
### :rocket: New Feature
- Bump compat-table for node8 support ([#363](https://github.com/babel/babel-preset-env/pull/363)) (@existentialism)
We updated our mappings to support native trailing function commas and string paddings in Node.js 8+.
### :bug: Bug Fix
- Handle `chromeandroid` browserslist value ([#367](https://github.com/babel/babel-preset-env/pull/367)) (@yavorsky)
We added support for using browserslist's `chromeandroid` in `targets`.
### :memo: Documentation
- Tweak uglify option docs ([#368](https://github.com/babel/babel-preset-env/pull/368)) (@existentialism)
Thanks to @graingert and @pfiaux for pointing out some needed updates to the `uglify-js`-related docs.
## v1.5.2 (2017-06-07)
### :bug: Bug Fix
- Ensure explicit targets always override browsers key targets ([#346](https://github.com/babel/babel-preset-env/pull/346)) (@existentialism)
`browser` targets should be overridden by explicit targets, and we inadvertently broke this when we landed string version support.
## v1.5.1 (2017-05-22)
### :bug: Bug Fix
- Compile with loose mode ([#322](https://github.com/babel/babel-preset-env/pull/332)) (@existentialism)
## v1.5.0 (2017-05-19)
### :rocket: New Feature
- Support target versions as strings ([#321](https://github.com/babel/babel-preset-env/pull/321)) (@existentialism)
We were originally waiting on 2.x for a breaking change, but since node v7.10
and other targets are causing some pain, we decided to land a backwards
compatible version.
### :house: Internal
- Backport: use preset-env and remove flow-strip-types ([#324](https://github.com/babel/babel-preset-env/pull/324)) (@yavorsky)
- Bump electron-to-chromium ([#329](https://github.com/babel/babel-preset-env/pull/329)) (@existentialism)
- Tweak version mappings to match compat-table updates ([#323](https://github.com/babel/babel-preset-env/pull/323)) (@existentialism)
- Bump browserslist ([#319](https://github.com/babel/babel-preset-env/pull/319)) (@existentialism)
- Bump compat-table ([#307](https://github.com/babel/babel-preset-env/pull/307)) (@existentialism)
- Add debug-fixtures and test/tmp to .eslintignore ([#305](https://github.com/babel/babel-preset-env/pull/305)) (@yavorsky)
## v1.4.0 (2017-04-14)
### :rocket: New Feature
- Support `spec` option ([#98](https://github.com/babel/babel-preset-env/pull/98)) (@Kovensky)
Added an option to enable more spec compliant, but potentially slower, transformations for any plugins in this preset that support them.
- Bump compat-table for Edge 15 support ([#273](https://github.com/babel/babel-preset-env/pull/273)) (@existentialism)
We updated our mappings so that you can get native support for async/await and other goodies when targeting Edge 15!
### :bug: Bug Fix
- Add Android browser to name map ([#270](https://github.com/babel/babel-preset-env/pull/270)) (@existentialism)
Fixed a bug that was ignoring Android targets in browserslist queries (for example: "Android >= 4").
### :memo: Documentation
- Clarify note about loading polyfills only once ([#282](https://github.com/babel/babel-preset-env/pull/282)) (@darahak)
- Add a reminder about include/exclude options ([#275](https://github.com/babel/babel-preset-env/pull/275)) (@existentialism)
### :house: Internal
- Chore: reduce package size. ([#281](https://github.com/babel/babel-preset-env/pull/281)) (@evilebottnawi)
- Remove deprecated comment ([#271](https://github.com/babel/babel-preset-env/pull/271)) (@yavorsky)
## v1.3.3 (2017-04-07)
### :bug: Bug Fix
- Support electron version in a string format ([#252](https://github.com/babel/babel-preset-env/pull/252)) (@yavorsky)
Adding electron as a target was an inadvertent breaking change as it no longer
allowed string versions. We added an exception for now, even though it is
inconsistent with other versions. Just as a note, the upcoming version 2.x will
allow _both_ number and string versions.
- Ensure const-check plugin order ([#257](https://github.com/babel/babel-preset-env/pull/257)) (@existentialism)
We now force the `const-es2015-check` plugin to run first (so that it can
correctly report issues before they get transpiled away).
### :rocket: New Feature
- Allow use `babel-plugin-` prefix for include and exclude ([#242](https://github.com/babel/babel-preset-env/pull/242)) (@yavorsky)
The `include` and `exclude` options now allow both prefixed (`babel-plugin-transform-es2015-spread`)
and prefix-less (`transform-es2015-spread`) plugin names.
### :memo: Documentation
- Note babel plugin prefix handling in include/exclude ([#245](https://github.com/babel/babel-preset-env/pull/245)) (@existentialism)
- Fix README: debug option shows info in stdout. ([#236](https://github.com/babel/babel-preset-env/pull/236)) (@Gerhut)
### :house: Internal
- Add simple smoke-test ([#240](https://github.com/babel/babel-preset-env/pull/240)) (@existentialism)
- Add prepublish script (@existentialism)
## v1.3.2 (2017-03-30)
- Fixed an issue with a broken publish
## v1.3.1 (2017-03-30)
- Fixed a regression with missing files due to `.npmignore`.
## v1.3.0 (2017-03-30)
### :bug: Bug Fix
- Add check for ArrayBuffer[Symbol.species] ([#233](https://github.com/babel/babel-preset-env/pull/233)) (@existentialism)
We now properly check for `Symbol.species` support in ArrayBuffer and include the
polyfill if necessary. This should, as a side effect, fix ArrayBuffer-related
errors on IE9.
### :nail_care: Polish
- Fill data with electron as a target. ([#229](https://github.com/babel/babel-preset-env/pull/229)) (@yavorsky)
We've simplified things by adding `electron` as a target instead of doing a bunch of
things at runtime. Electron targets should now also be displayed in the debug output.
- separate default builtins for platforms ([#226](https://github.com/babel/babel-preset-env/pull/226)) (@restrry)
If you are targeting the `node` environment exclusively, the always-included web polyfills
(like `dom.iterable`, and a few others) will now no longer be included.
### :memo: Documentation
* remove deprecated projects ([#223](https://github.com/babel/babel-preset-env/pull/223)) [skip ci] (@stevemao)
### :house: Internal
* npmignore: Add related to build data and codecov. ([#216](https://github.com/babel/babel-preset-env/pull/216)) (@yavorsky)
## v1.2.2 (2017-03-14)
### :bug: Bug Fix
- Refactor browser data parsing to handle families ([#208](https://github.com/babel/babel-preset-env/pull/208)) (@existentialism)
When parsing plugin data, we weren't properly handling browser families. This caused
`transform-es2015-block-scoping` and other plugins to be incorrectly added for Edge >= 12.
(s/o to @mgol for the the report and review!)
- Add typed array methods to built-ins features. ([#198](https://github.com/babel/babel-preset-env/pull/198)) (@yavorsky)
Fixes an issue where some TypedArray features were not being polyfilled properly. (s/o to @alippai for the report!)
### :memo: Documentation
- Fixed minor typo in readme ([#199](https://github.com/babel/babel-preset-env/pull/199)) (@bl4ckdu5t)
- Add built-ins, better links, compat-table url, etc ([#195](https://github.com/babel/babel-preset-env/pull/195)) (@yavorsky)
- Change CONTRIBUTING.md to use absolute paths ([#194](https://github.com/babel/babel-preset-env/pull/194)) (@aaronang)
### :house: Internal
- Bump plugins ([#201](https://github.com/babel/babel-preset-env/pull/201)) (@yavorsky)
- Enable code coverage ([#200](https://github.com/babel/babel-preset-env/pull/200)) (@alxpy)
- Increase mocha timeout to 10s ([#202](https://github.com/babel/babel-preset-env/pull/202)) (@yavorsky)
## v1.2.1 (2017-03-06)
### :bug: Bug Fix
- Add transform-duplicate-keys mapping ([#192](https://github.com/babel/babel-preset-env/pull/192)) (@existentialism)
Our plugin data was missing a mapping for the `transform-duplicate-keys` plugin which caused it to never be included. (s/o to @Timer for the report!)
### :memo: Documentation
- Clarify reasons for the uglify option in README.md ([#188](https://github.com/babel/babel-preset-env/pull/188)) (@mikegreiling)
## v1.2.0 (2017-03-03)
### :rocket: New Feature
- Add uglify as a target ([#178](https://github.com/babel/babel-preset-env/pull/178)) (@yavorsky)
Support for `uglify` as a target is now available! This will enable all plugins and, as a result, fully compiles your code to ES5. Note, that useBuiltIns will work as before, and only the polyfills that your other target(s) need will be included.
```json
{
"presets": [
["env", {
"targets": {
"chrome": 55,
"uglify": true
},
"useBuiltIns": true,
"modules": false
}]
]
}
```
### :bug: Bug Fix
- Respect older versions in invert equals map ([#180](https://github.com/babel/babel-preset-env/pull/180)) (@danez)
Fixes a number of bugs that caused some incorrect and/or missing environment data when parsing `compat-table`.
## v1.1.11 (2017-03-01)
This release primarily upgrades `compat-table`, which adds support for async on Node 7.6!
### :bug: Bug Fix
- Fix hasBeenWarned condition. ([#175](https://github.com/babel/babel-preset-env/pull/175)) (@yavorsky)
### :memo: Documentation
- Add yarn example. ([#174](https://github.com/babel/babel-preset-env/pull/174)) (@yavorsky)
### :house: Internal
- Bump compat-table ([#177](https://github.com/babel/babel-preset-env/pull/177)) (@existentialism)
- Add electron version exception test ([#176](https://github.com/babel/babel-preset-env/pull/176)) (@existentialism)
## v1.1.10 (2017-02-24)
### :bug: Bug Fix
- Drop use of lodash/intersection from checkDuplicateIncludeExcludes ([#173](https://github.com/babel/babel-preset-env/pull/173)) (@existentialism)
## v1.1.9 (2017-02-24)
### :bug: Bug Fix
- Add tests for debug output ([#156](https://github.com/babel/babel-preset-env/pull/156)) (@existentialism)
Since we've (mostly @yavorsky) have fixed a number of bugs recently with the `debug` option output, we added the ability to assert stdout matches what we expect. Read the updated [CONTRIBUTING.md](https://github.com/babel/babel-preset-env/blob/master/CONTRIBUTING.md#testing-the-debug-option) for more info.
- Fixes #143. Log correct targets. ([#155](https://github.com/babel/babel-preset-env/pull/155)) (@yavorsky)
This fixes a bug in the `debug` output where incorrect target(s) were being displayed for why a particular plugin/preset was being included.
Given targets:
```txt
{
"firefox": 52,
"node": 7.4
}
```
Before:
```txt
Using plugins:
transform-es2015-destructuring {"node":6.5}
transform-es2015-for-of {"node":6.5}
transform-es2015-function-name {"node":6.5}
transform-es2015-literals {"node":4}
transform-exponentiation-operator {"firefox":52}
syntax-trailing-function-commas {"firefox":52}
```
After:
```txt
Using plugins:
transform-es2015-destructuring {"firefox":52}
transform-es2015-for-of {"firefox":52}
transform-es2015-function-name {"firefox":52}
transform-es2015-literals {"firefox":52}
transform-exponentiation-operator {"node":7.4}
syntax-trailing-function-commas {"node":7.4}
```
### :memo: Documentation
- Fix compat-table link in contributing.md (@existentialism)
- Update README examples to fix website ([#151](https://github.com/babel/babel-preset-env/pull/)) (@existentialism)
- Fix few typos ([#146](https://github.com/babel/babel-preset-env/pull/146)) (@existentialism)
- Add configuration example to clarify `debug: true` ([#138](https://github.com/babel/babel-preset-env/pull/138)) (@yavorsky)
- Fix CHANGELOGs v1.1.8 updates typo. ([#136](https://github.com/babel/babel-preset-env/pull/136)) (@yavorsky)
- README: Update `debug: true` example. ([#138](https://github.com/babel/babel-preset-env/pull/138)) (@yavorsky)
### :house: Internal
- update compat ([#169](https://github.com/babel/babel-preset-env/pull/169)) (@hzoo)
- Use external Electron to Chromium library ([#144](https://github.com/babel/babel-preset-env/pull/144)) (@Kilian)
- Update yarn lockfile ([#152](https://github.com/babel/babel-preset-env/pull/152)) (@existentialism)
- Extract option normalization into independant file ([#125](https://github.com/babel/babel-preset-env/pull/125)) (@baer)
- Update yarnfile ([#145](https://github.com/babel/babel-preset-env/pull/145)) (@baer)
- devDeps: eslint-config-babel v5.0.0 ([#139](https://github.com/babel/babel-preset-env/pull/139)) (@kaicataldo)
- Update compat-table, build data ([#135](https://github.com/babel/babel-preset-env/pull/135)) (@hzoo)
## v1.1.8 (2017-01-10)
### :bug: Bug Fix
- Debug: Transformations before logs. ([#128](https://github.com/babel/babel-preset-env/pull/128)) (@yavorsky)
Makes sure that all transformations on `targets` (such as `exclude`/`include`) are run before logging out with the `debug` option. Fixes ([#127](https://github.com/babel/babel-preset-env/issues/127)).
### :house: Internal
- Remove unnecessary extension. ([#131](https://github.com/babel/babel-preset-env/pull/131)) (@roman-yakobnyuk)
- Include yarn.lock and update CI. ([#124](https://github.com/babel/babel-preset-env/pull/124)) (@existentialism)
## v1.1.7 (2017-01-09)
Had a publishing issue in the previous release.
## v1.1.6 (2017-01-06)
### :bug: Bug Fix
- Explicitly resolve lowest browser version. ([#121](https://github.com/babel/babel-preset-env/pull/121)) (@brokenmass)
```js
{
"targets": {
"browsers": ["ios >= 6"] // was resolving to {ios: 10} rather than {ios: 6}
}
}
```
## v1.1.5 (2017-01-04)
### :bug: Bug Fix
- Show error if target version is not a number. ([#107](https://github.com/babel/babel-preset-env/pull/107)) (@existentialism)
```js
{
"presets": [
["env", {
"targets": {
"chrome": "52", // will error since it's not a number,
"chrome": 52 // correct!
}
}]
]
}
```
- Fix targets for the `debug` option. ([#109](https://github.com/babel/babel-preset-env/pull/109)) (@yavorsky)
Now it prints the transformed targets/environments rather than the browsers query.
```txt
Using targets:
{
"chrome": 53,
"ie": 10,
"node": 6
}
Modules transform: false
Using plugins:
transform-es2015-arrow-functions {"chrome":47,"node":6}
transform-es2015-block-scoped-functions {"chrome":41,"ie":11,"node":4}
Using polyfills:
es6.typed.uint8-clamped-array {"chrome":5,"node":0.12}
es6.map {"chrome":51,"node":6.5}
```
## v1.1.4 (2016-12-16)
v1.1.2-v1.1.4
### :bug: Bug Fix
The new `exclude`/`include` options weren't working correctly for built-ins. ([#102](https://github.com/babel/babel-preset-env/pull/102)).
Also fixes an issue with debug option.
## v1.1.1 (2016-12-13)
### :bug: Bug Fix
Regression with the previous release due to using `Object.values` (ES2017). This wasn't caught because we are using babel-register to run tests and includes polyfills so it didn't fail on CI even though we have Node 0.10 as an env. Looking into fixing this to prevent future issues.
## v1.1.0 (2016-12-13)
### :rocket: New Feature
- Add `exclude` option, rename `whitelist` to `include` ([#89](https://github.com/babel/babel-preset-env/pull/89)) (@hzoo)
Example:
```js
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
},
"include": ["transform-es2015-arrow-functions"],
"exclude": [
"transform-regenerator",
"transform-async-to-generator",
"map"
],
"useBuiltIns": true
}]
]
}
```
`"exclude": ["transform-regenerator"]` doesn't transform generators and removes `regeneratorRuntime` from being imported.
`"exclude": ["transform-async-to-generator"]` doesn't use the built-in async-to-gen transform so you can use something like [fast-async](https://github.com/MatAtBread/fast-async).
`"exclude": ["map"]` doesn't include the `Map` polyfill if you know you aren't using it in your code (w/ `useBuiltIns`). (We will figure out a way to automatically do this [#84](https://github.com/babel/babel-preset-env/issues/84)).
If you pass a wrong plugin it will error: valid options for `include/exclude` are in [/data/plugin-features.js](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js) and [/data/built-in-features.js](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js) (without the `es6.`)
### :house: Internal
- Optimize result filtration. ([#77](https://github.com/babel/babel-preset-env/pull/77)) (@yavorsky)
- Update eslint config to align with other babel projects ([#79](https://github.com/babel/babel-preset-env/pull/79)) (@baer)
- Update pathnames to avoid uppercase ([#80](https://github.com/babel/babel-preset-env/pull/80)) (@baer)
- Refactor build data for clarity/consistency ([#81](https://github.com/babel/babel-preset-env/pull/81)) (@baer)
- Update linting rules to cover all js ([#82](https://github.com/babel/babel-preset-env/pull/82)) (@baer)
- Cleanup lib before rebuilding ([#87](https://github.com/babel/babel-preset-env/pull/87)) (@baer)
- Move linting dependency to be dev only ([#88](https://github.com/babel/babel-preset-env/pull/88)) (@baer)
### :memo: Documentation
- Fix typo ([#78](https://github.com/babel/babel-preset-env/pull/78)) (@rohmanhm)
- Fix PR link in changelog. ([#75](https://github.com/babel/babel-preset-env/pull/75)) (@nhajidin)
## v1.0.2 (2016-12-10)
### :bug: Bug Fix
* Fix issue with Object.getOwnPropertySymbols ([#71](https://github.com/babel/babel-preset-env/pull/71)) ([@existentialism](https://github.com/existentialism))
Was requiring the wrong module kinda of like in v1.0.1:
https://github.com/zloirock/core-js#ecmascript-6-symbol
```diff
-import "core-js/modules/es6.object.get-own-property-symbols";
```
The test is just a part of `Symbol`.
## v1.0.1 (2016-12-10)
### :bug: Bug Fix
* Fix regenerator import ([#68](https://github.com/babel/babel-preset-env/pull/68)) ([@hzoo](https://github.com/hzoo))
We were outputting an invalid path for `regenerator`!
```diff
+import "regenerator-runtime/runtime";
-import "core-js/modules/regenerator-runtime/runtime"-
```
## v1.0.0 (2016-12-09)
### :rocket: New Feature
* Add `useBuiltIns` option ([#56](https://github.com/babel/babel-preset-env/pull/56)) ([@hzoo](https://github.com/hzoo)), ([@yavorsky](https://github.com/yavorsky)), ([@existentialism](https://github.com/existentialism))
A way to apply `babel-preset-env` for polyfills (via `"babel-polyfill"``).
> This option will apply a new Babel plugin that replaces `require("babel-polyfill")` with the individual requires for `babel-polyfill` based on the target environments.
Install
```
npm install babel-polyfill --save
```
In
```js
import "babel-polyfill"; // create an entry js file that contains this
// or
import "core-js";
```
Out (different based on environment)
```js
// chrome 55
import "core-js/modules/es7.string.pad-start"; // haha left_pad
import "core-js/modules/es7.string.pad-end";
import "core-js/modules/web.timers";
import "core-js/modules/web.immediate";
import "core-js/modules/web.dom.iterable";
```
`.babelrc` Usage
```js
{
"presets": [
["env", {
"targets": {
"electron": 1.4
},
"modules": false, // webpack 2
"useBuiltIns": true // new option
}]
]
}
```
> Also looking to make an easier integration point via Webpack with this method. Please reach out if you have ideas!
---
* Support [Electron](http://electron.atom.io/) ([#55](https://github.com/babel/babel-preset-env/pull/55)) ([@paulcbetts](https://github.com/paulcbetts))
Electron is also an environment, so [Paul went ahead](https://twitter.com/paulcbetts/status/804507070103851008) and added support for this!
`.babelrc` Usage
```js
{
"presets": [ ["env", {"targets": { "electron": 1.4 }}]]
}
```
> Currently we are manually updating the data in [/data/electron-to-chromium.js](https://github.com/babel/babel-preset-env/blob/master/data/electron-to-chromium.js), but [@kevinsawicki](https://github.com/kevinsawicki) says we could generate the data from [atom-shell/dist/index.json](https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/index.json) as well! (Someone should make a PR :smile:)
## v0.0.9 (2016-11-24)
### :rocket: New Feature
* Support Opera ([#48](https://github.com/babel/babel-preset-env/pull/48)) (Henry Zhu)
Was as simple as modifying the chrome version and subtracting 13! (so chrome 54 = opera 41)
```js
{
"presets": [
["env", {
"targets": {
"opera": 41
}
}]
]
}
```
## v0.0.8 (2016-11-16)
### :nail_care: Polish
* Only print the debug info once ([#46](https://github.com/babel/babel-preset-env/pull/46) (Henry Zhu)
When using the `debug` option it was printing the data for each file processed rather than once.
```js
{
"presets": [
["env", {
"debug": true
}]
]
}
```
## v0.0.7 (2016-11-02)
### :rocket: New Feature
* hardcode a current node version option ([#35](https://github.com/babel/babel-preset-env/pull/35)) (Henry Zhu)
```js
{
"presets": [
["env", {
"targets": {
"node": "current" // parseFloat(process.versions.node)
}
}]
]
}
```
* add 'whitelist' option ([#31](https://github.com/babel/babel-preset-env/pull/31)) (Henry Zhu)
```js
{
"presets": [
["env", {
"targets": {
"chrome": 52
},
"whitelist": ["transform-es2015-arrow-functions"]
}]
]
}
```
* Add more aliases (Henry Zhu)
* Update plugin data: firefox 52 supports async/await! ([#29](https://github.com/babel/babel-preset-env/pull/29)) (Henry Zhu)
### :bug: Bug Fixes
* Use compat-table equals option ([#36](https://github.com/babel/babel-preset-env/pull/36)) (Henry Zhu)
Compute and use `compat-table` equivalents
```js
{
"safari6": "phantom",
"chrome44": "iojs",
"chrome50": "node64",
"chrome51": "node65",
"chrome54": "node7",
"chrome30": "android44",
"chrome37": "android50",
"chrome39": "android51",
"safari7": "ios7",
"safari71_8": "ios8",
"safari9": "ios9",
"safari10": "ios10",
"chrome50": "node6"
}
```
* Change default behavior to act the same as babel-preset-latest ([#33](https://github.com/babel/babel-preset-env/pull/33)) (Henry Zhu)
```js
{ "presets": ["env"] } // should act the same as babel-preset-latest
```
## Internal
* Add fixture helper for tests ([#28](https://github.com/babel/babel-preset-env/pull/28)) (Henry Zhu)

View File

@@ -0,0 +1,93 @@
# Contributing
## Adding a new plugin to support (when approved in the next ECMAScript version)
### Update [`plugin-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js)
*Example:*
If you were going to add `**` which is in ES2016:
Find the relevant entries on [compat-table](https://kangax.github.io/compat-table/es2016plus/#test-exponentiation_(**)_operator):
`exponentiation (**) operator`
Find the corresponding babel plugin:
`transform-exponentiation-operator`
And add them in this structure:
```js
// es2016
"transform-exponentiation-operator": {
features: [
"exponentiation (**) operator",
],
},
```
### Update [`built-in-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js)
*Example:*
In case you want to add `Object.values` which is in ES2017:
Find the relevant feature and subfeature on [compat-table](https://kangax.github.io/compat-table/es2016plus/#test-Object_static_methods_Object.values)
and split it with `/`:
`Object static methods / Object.values`
Find the corresponding module on [core-js](https://github.com/zloirock/core-js/tree/master/modules):
`es7.object.values.js`
Find required ES version in [`built-in-features.js`](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js) and add the new feature:
```js
const es2017 = {
//...
"es7.object.values": "Object static methods / Object.values"
}
```
### Update [`plugins.json`](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json)
Until `compat-table` is a standalone npm module for data we are using the git url
`"compat-table": "kangax/compat-table#[latest-commit-hash]"`,
So we update and then run `npm run build-data`. If there are no changes, then `plugins.json` will be the same.
## Tests
### Running tests locally
```bash
npm test
```
### Checking code coverage locally
```bash
npm run coverage
```
### Writing tests
#### General
All the tests for `babel-preset-env` exist in the `test/fixtures` folder. The
test setup and conventions are exactly the same as testing a Babel plugin, so
please read our [documentation on writing tests](https://github.com/babel/babel/blob/master/CONTRIBUTING.md#babel-plugin-x).
#### Testing the `debug` option
Testing debug output to `stdout` is similar. Under the `test/debug-fixtures`,
create a folder with a descriptive name of your test, and add the following:
* Add a `options.json` file (just as the other tests, this is essentially a
`.babelrc`) with the desired test configuration (required)
* Add a `stdout.txt` file with the expected debug output. For added
convenience, if there is no `stdout.txt` present, the test runner will
generate one for you.

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016-2017 Babel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,459 @@
# Now that `babel-preset-env` has stabilized, it has been [moved into the main Babel mono-repo](https://github.com/babel/babel/tree/master/packages/babel-preset-env) and this repo has been archived.
The move makes it much easier to release and develop in sync with the rest of Babel!
This repo will be made read-only, as all of the issues/labels have been moved over as well. Please report any bugs and open pull requests over on the [main mono-repo](https://github.com/babel/babel).
---
# babel-preset-env [![npm](https://img.shields.io/npm/v/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![travis](https://img.shields.io/travis/babel/babel-preset-env/master.svg)](https://travis-ci.org/babel/babel-preset-env) [![npm-downloads](https://img.shields.io/npm/dm/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![codecov](https://img.shields.io/codecov/c/github/babel/babel-preset-env/master.svg?maxAge=43200)](https://codecov.io/github/babel/babel-preset-env)
> A Babel preset that compiles [ES2015+](https://github.com/tc39/proposals/blob/master/finished-proposals.md) down to ES5 by automatically determining the Babel plugins and polyfills you need based on your targeted browser or runtime environments.
```sh
npm install babel-preset-env --save-dev
```
Without any configuration options, babel-preset-env behaves exactly the same as babel-preset-latest (or babel-preset-es2015, babel-preset-es2016, and babel-preset-es2017 together).
> However, we don't recommend using `preset-env` this way because it doesn't take advantage of it's greater capabilities of targeting specific browsers.
```json
{
"presets": ["env"]
}
```
You can also configure it to only include the polyfills and transforms needed for the browsers you support. Compiling only what's needed can make your bundles smaller and your life easier.
This example only includes the polyfills and code transforms needed for coverage of users > 0.25%, ignoring Internet Explorer 11 and Opera Mini.. We use [browserslist](https://github.com/ai/browserslist) to parse this information, so you can use [any valid query format supported by browserslist](https://github.com/ai/browserslist#queries).
```js
{
"presets": [
["env", {
"targets": {
// The % refers to the global coverage of users from browserslist
"browsers": [ ">0.25%", "not ie 11", "not op_mini all"]
}
}]
]
}
```
> You can also target individual versions of browsers instead of using a query with `"targets": { "chrome": "52" }`.
Similarly, if you're targeting Node.js instead of the browser, you can configure babel-preset-env to only include the polyfills and transforms necessary for a particular version:
```json
{
"presets": [
["env", {
"targets": {
"node": "6.10"
}
}]
]
}
```
For convenience, you can use `"node": "current"` to only include the necessary polyfills and transforms for the Node.js version that you use to run Babel:
```json
{
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
]
}
```
Check out the many options (especially `useBuiltIns` to polyfill less)!
- [How it Works](#how-it-works)
- [Install](#install)
- [Usage](#usage)
- [Options](#options)
- [Examples](#examples)
- [Caveats](#caveats)
- [Other Cool Projects](#other-cool-projects)
## How it Works
### Determine environment support for ECMAScript features
Use external data such as [`compat-table`](https://github.com/kangax/compat-table) to determine browser support. (We should create PRs there when necessary)
![](https://cloud.githubusercontent.com/assets/588473/19214029/58deebce-8d48-11e6-9004-ee3fbcb75d8b.png)
We can periodically run [build-data.js](https://github.com/babel/babel-preset-env/blob/master/scripts/build-data.js) which generates [plugins.json](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json).
Ref: [#7](https://github.com/babel/babel-preset-env/issues/7)
### Maintain a mapping between JavaScript features and Babel plugins
> Currently located at [plugin-features.js](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js).
This should be straightforward to do in most cases. There might be cases where plugins should be split up more or certain plugins aren't standalone enough (or impossible to do).
### Support all plugins in Babel that are considered `latest`
> Default behavior without options is the same as `babel-preset-latest`.
It won't include `stage-x` plugins. env will support all plugins in what we consider the latest version of JavaScript (by matching what we do in [`babel-preset-latest`](http://babeljs.io/docs/plugins/preset-latest/)).
Ref: [#14](https://github.com/babel/babel-preset-env/issues/14)
### Determine the lowest common denominator of plugins to be included in the preset
If you are targeting IE 8 and Chrome 55 it will include all plugins required by IE 8 since you would need to support both still.
### Support a target option `"node": "current"` to compile for the currently running node version.
For example, if you are building on Node 6, arrow functions won't be converted, but they will if you build on Node 0.12.
### Support a `browsers` option like autoprefixer
Use [browserslist](https://github.com/ai/browserslist) to declare supported environments by performing queries like `> 1%, last 2 versions`.
Ref: [#19](https://github.com/babel/babel-preset-env/pull/19)
## Install
With [npm](https://www.npmjs.com):
```sh
npm install --save-dev babel-preset-env
```
Or [yarn](https://yarnpkg.com):
```sh
yarn add babel-preset-env --dev
```
## Usage
The default behavior without options runs all transforms (behaves the same as [babel-preset-latest](https://babeljs.io/docs/plugins/preset-latest/)).
```json
{
"presets": ["env"]
}
```
## Options
For more information on setting options for a preset, refer to the [plugin/preset options](http://babeljs.io/docs/plugins/#plugin-preset-options) documentation.
### `targets`
`{ [string]: number | string }`, defaults to `{}`.
Takes an object of environment versions to support.
Each target environment takes a number or a string (we recommend using a string when specifying minor versions like `node: "6.10"`).
Example environments: `chrome`, `opera`, `edge`, `firefox`, `safari`, `ie`, `ios`, `android`, `node`, `electron`.
The [data](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json) for this is generated by running the [build-data script](https://github.com/babel/babel-preset-env/blob/master/scripts/build-data.js) which pulls in data from [compat-table](https://kangax.github.io/compat-table).
### `targets.node`
`number | string | "current" | true`
If you want to compile against the current node version, you can specify `"node": true` or `"node": "current"`, which would be the same as `"node": process.versions.node`.
### `targets.browsers`
`Array<string> | string`
A query to select browsers (ex: last 2 versions, > 5%) using [browserslist](https://github.com/ai/browserslist).
Note, browsers' results are overridden by explicit items from `targets`.
### `targets.uglify`
`true`
When using `uglify-js` to minify your code, you may run into syntax errors when targeting later browsers since `uglify-js` does not support any ES2015+ syntax.
To prevent these errors - set the `uglify` option to `true`, which enables all transformation plugins and as a result, your code is fully compiled to ES5. However, the `useBuiltIns` option will still work as before and only include the polyfills that your target(s) need.
> Uglify has support for ES2015 syntax via [uglify-es](https://github.com/mishoo/UglifyJS2/tree/harmony). If you are using syntax unsupported by `uglify-es`, we recommend using [babel-minify](https://github.com/babel/minify).
> Note: This option is deprecated in 2.x and replaced with a [`forceAllTransforms` option](https://github.com/babel/babel-preset-env/pull/264).
### `spec`
`boolean`, defaults to `false`.
Enable more spec compliant, but potentially slower, transformations for any plugins in this preset that support them.
### `loose`
`boolean`, defaults to `false`.
Enable "loose" transformations for any plugins in this preset that allow them.
### `modules`
`"amd" | "umd" | "systemjs" | "commonjs" | false`, defaults to `"commonjs"`.
Enable transformation of ES6 module syntax to another module type.
Setting this to `false` will not transform modules.
### `debug`
`boolean`, defaults to `false`.
Outputs the targets/plugins used and the version specified in [plugin data version](https://github.com/babel/babel-preset-env/blob/master/data/plugins.json) to `console.log`.
### `include`
`Array<string>`, defaults to `[]`.
> NOTE: `whitelist` is deprecated and will be removed in the next major in favor of this.
An array of plugins to always include.
Valid options include any:
- [Babel plugins](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js) - both with (`babel-plugin-transform-es2015-spread`) and without prefix (`transform-es2015-spread`) are supported.
- [Built-ins](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js), such as `map`, `set`, or `object.assign`.
This option is useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work.
For example, Node 4 supports native classes but not spread. If `super` is used with a spread argument, then the `transform-es2015-classes` transform needs to be `include`d, as it is not possible to transpile a spread with `super` otherwise.
> NOTE: The `include` and `exclude` options _only_ work with the [plugins included with this preset](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js); so, for example, including `transform-do-expressions` or excluding `transform-function-bind` will throw errors. To use a plugin _not_ included with this preset, add them to your [config](https://babeljs.io/docs/usage/babelrc/) directly.
### `exclude`
`Array<string>`, defaults to `[]`.
An array of plugins to always exclude/remove.
The possible options are the same as the `include` option.
This option is useful for "blacklisting" a transform like `transform-regenerator` if you don't use generators and don't want to include `regeneratorRuntime` (when using `useBuiltIns`) or for using another plugin like [fast-async](https://github.com/MatAtBread/fast-async) instead of [Babel's async-to-gen](http://babeljs.io/docs/plugins/transform-async-generator-functions/).
### `useBuiltIns`
`boolean`, defaults to `false`.
A way to apply `babel-preset-env` for polyfills (via "babel-polyfill").
> NOTE: This does not currently polyfill experimental/stage-x built-ins like the regular "babel-polyfill" does.
> This will only work with npm >= 3 (which should be used with Babel 6 anyway)
```
npm install babel-polyfill --save
```
This option enables a new plugin that replaces the statement `import "babel-polyfill"` or `require("babel-polyfill")` with individual requires for `babel-polyfill` based on environment.
> NOTE: Only use `require("babel-polyfill");` once in your whole app.
> Multiple imports or requires of `babel-polyfill` will throw an error since it can cause global collisions and other issues that are hard to trace.
> We recommend creating a single entry file that only contains the `require` statement.
**In**
```js
import "babel-polyfill";
```
**Out (different based on environment)**
```js
import "core-js/modules/es7.string.pad-start";
import "core-js/modules/es7.string.pad-end";
import "core-js/modules/web.timers";
import "core-js/modules/web.immediate";
import "core-js/modules/web.dom.iterable";
```
This will also work for `core-js` directly (`import "core-js";`)
```
npm install core-js --save
```
---
## Examples
### Export with various targets
```js
export class A {}
```
#### Target only Chrome 52
**.babelrc**
```json
{
"presets": [
["env", {
"targets": {
"chrome": 52
}
}]
]
}
```
**Out**
```js
class A {}
exports.A = A;
```
#### Target Chrome 52 with webpack 2/rollup and loose mode
**.babelrc**
```json
{
"presets": [
["env", {
"targets": {
"chrome": 52
},
"modules": false,
"loose": true
}]
]
}
```
**Out**
```js
export class A {}
```
#### Target specific browsers via browserslist
**.babelrc**
```json
{
"presets": [
["env", {
"targets": {
"chrome": 52,
"browsers": ["last 2 versions", "safari 7"]
}
}]
]
}
```
**Out**
```js
export var A = function A() {
_classCallCheck(this, A);
};
```
#### Target latest node via `node: true` or `node: "current"`
**.babelrc**
```json
{
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
]
}
```
**Out**
```js
class A {}
exports.A = A;
```
### Show debug output
**.babelrc**
```json
{
"presets": [
[ "env", {
"targets": {
"safari": 10
},
"modules": false,
"useBuiltIns": true,
"debug": true
}]
]
}
```
**stdout**
```sh
Using targets:
{
"safari": 10
}
Modules transform: false
Using plugins:
transform-exponentiation-operator {}
transform-async-to-generator {}
Using polyfills:
es7.object.values {}
es7.object.entries {}
es7.object.get-own-property-descriptors {}
web.timers {}
web.immediate {}
web.dom.iterable {}
```
### Include and exclude specific plugins/built-ins
> always include arrow functions, explicitly exclude generators
```json
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
},
"include": ["transform-es2015-arrow-functions", "es6.map"],
"exclude": ["transform-regenerator", "es6.set"]
}]
]
}
```
## Caveats
If you get a `SyntaxError: Unexpected token ...` error when using the [object-rest-spread](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-object-rest-spread) transform then make sure the plugin has been updated to, at least, `v6.19.0`.
## Other Cool Projects
- [babel-preset-modern-browsers](https://github.com/christophehurpeau/babel-preset-modern-browsers)
- ?

View File

@@ -0,0 +1,193 @@
// https://github.com/zloirock/core-js
const typedArrayMethods = [
"typed arrays / %TypedArray%.from",
"typed arrays / %TypedArray%.of",
"typed arrays / %TypedArray%.prototype.subarray",
"typed arrays / %TypedArray%.prototype.join",
"typed arrays / %TypedArray%.prototype.indexOf",
"typed arrays / %TypedArray%.prototype.lastIndexOf",
"typed arrays / %TypedArray%.prototype.slice",
"typed arrays / %TypedArray%.prototype.every",
"typed arrays / %TypedArray%.prototype.filter",
"typed arrays / %TypedArray%.prototype.forEach",
"typed arrays / %TypedArray%.prototype.map",
"typed arrays / %TypedArray%.prototype.reduce",
"typed arrays / %TypedArray%.prototype.reduceRight",
"typed arrays / %TypedArray%.prototype.reverse",
"typed arrays / %TypedArray%.prototype.some",
"typed arrays / %TypedArray%.prototype.sort",
"typed arrays / %TypedArray%.prototype.copyWithin",
"typed arrays / %TypedArray%.prototype.find",
"typed arrays / %TypedArray%.prototype.findIndex",
"typed arrays / %TypedArray%.prototype.fill",
"typed arrays / %TypedArray%.prototype.keys",
"typed arrays / %TypedArray%.prototype.values",
"typed arrays / %TypedArray%.prototype.entries",
"typed arrays / %TypedArray%.prototype[Symbol.iterator]",
"typed arrays / %TypedArray%[Symbol.species]",
];
const es2015 = {
"es6.typed.array-buffer": "typed arrays / ArrayBuffer[Symbol.species]",
"es6.typed.data-view": "typed arrays / DataView",
"es6.typed.int8-array": {
features: ["typed arrays / Int8Array"].concat(typedArrayMethods)
},
"es6.typed.uint8-array": {
features: ["typed arrays / Uint8Array"].concat(typedArrayMethods)
},
"es6.typed.uint8-clamped-array": {
features: ["typed arrays / Uint8ClampedArray"].concat(typedArrayMethods)
},
"es6.typed.int16-array": {
features: ["typed arrays / Int16Array"].concat(typedArrayMethods)
},
"es6.typed.uint16-array": {
features: ["typed arrays / Uint16Array"].concat(typedArrayMethods)
},
"es6.typed.int32-array": {
features: ["typed arrays / Int32Array"].concat(typedArrayMethods)
},
"es6.typed.uint32-array": {
features: ["typed arrays / Uint32Array"].concat(typedArrayMethods)
},
"es6.typed.float32-array": {
features: ["typed arrays / Float32Array"].concat(typedArrayMethods)
},
"es6.typed.float64-array": {
features: ["typed arrays / Float64Array"].concat(typedArrayMethods)
},
"es6.map": "Map",
"es6.set": "Set",
"es6.weak-map": "WeakMap",
"es6.weak-set": "WeakSet",
// Proxy not implementable
"es6.reflect.apply": "Reflect / Reflect.apply",
"es6.reflect.construct": "Reflect / Reflect.construct",
"es6.reflect.define-property": "Reflect / Reflect.defineProperty",
"es6.reflect.delete-property": "Reflect / Reflect.deleteProperty",
"es6.reflect.get": "Reflect / Reflect.get",
"es6.reflect.get-own-property-descriptor": "Reflect / Reflect.getOwnPropertyDescriptor",
"es6.reflect.get-prototype-of": "Reflect / Reflect.getPrototypeOf",
"es6.reflect.has": "Reflect / Reflect.has",
"es6.reflect.is-extensible": "Reflect / Reflect.isExtensible",
"es6.reflect.own-keys": "Reflect / Reflect.ownKeys",
"es6.reflect.prevent-extensions": "Reflect / Reflect.preventExtensions",
"es6.reflect.set": "Reflect / Reflect.set",
"es6.reflect.set-prototype-of": "Reflect / Reflect.setPrototypeOf",
"es6.promise": "Promise",
"es6.symbol": {
features: [
"Symbol",
"Object static methods / Object.getOwnPropertySymbols",
"well-known symbols / Symbol.hasInstance",
"well-known symbols / Symbol.isConcatSpreadable",
"well-known symbols / Symbol.iterator",
"well-known symbols / Symbol.match",
"well-known symbols / Symbol.replace",
"well-known symbols / Symbol.search",
"well-known symbols / Symbol.species",
"well-known symbols / Symbol.split",
"well-known symbols / Symbol.toPrimitive",
"well-known symbols / Symbol.toStringTag",
"well-known symbols / Symbol.unscopables",
]
},
"es6.object.freeze": "Object static methods accept primitives / Object.freeze",
"es6.object.seal": "Object static methods accept primitives / Object.seal",
"es6.object.prevent-extensions": "Object static methods accept primitives / Object.preventExtensions",
"es6.object.is-frozen": "Object static methods accept primitives / Object.isFrozen",
"es6.object.is-sealed": "Object static methods accept primitives / Object.isSealed",
"es6.object.is-extensible": "Object static methods accept primitives / Object.isExtensible",
"es6.object.get-own-property-descriptor":
"Object static methods accept primitives / Object.getOwnPropertyDescriptor",
"es6.object.get-prototype-of": "Object static methods accept primitives / Object.getPrototypeOf",
"es6.object.keys": "Object static methods accept primitives / Object.keys",
"es6.object.get-own-property-names": "Object static methods accept primitives / Object.getOwnPropertyNames",
"es6.object.assign": "Object static methods / Object.assign",
"es6.object.is": "Object static methods / Object.is",
"es6.object.set-prototype-of": "Object static methods / Object.setPrototypeOf",
"es6.function.name": "function \"name\" property",
"es6.string.raw": "String static methods / String.raw",
"es6.string.from-code-point": "String static methods / String.fromCodePoint",
"es6.string.code-point-at": "String.prototype methods / String.prototype.codePointAt",
// "String.prototype methods / String.prototype.normalize" not implemented
"es6.string.repeat": "String.prototype methods / String.prototype.repeat",
"es6.string.starts-with": "String.prototype methods / String.prototype.startsWith",
"es6.string.ends-with": "String.prototype methods / String.prototype.endsWith",
"es6.string.includes": "String.prototype methods / String.prototype.includes",
"es6.regexp.flags": "RegExp.prototype properties / RegExp.prototype.flags",
"es6.regexp.match": "RegExp.prototype properties / RegExp.prototype[Symbol.match]",
"es6.regexp.replace": "RegExp.prototype properties / RegExp.prototype[Symbol.replace]",
"es6.regexp.split": "RegExp.prototype properties / RegExp.prototype[Symbol.split]",
"es6.regexp.search": "RegExp.prototype properties / RegExp.prototype[Symbol.search]",
"es6.array.from": "Array static methods / Array.from",
"es6.array.of": "Array static methods / Array.of",
"es6.array.copy-within": "Array.prototype methods / Array.prototype.copyWithin",
"es6.array.find": "Array.prototype methods / Array.prototype.find",
"es6.array.find-index": "Array.prototype methods / Array.prototype.findIndex",
"es6.array.fill": "Array.prototype methods / Array.prototype.fill",
"es6.array.iterator": {
features: [
"Array.prototype methods / Array.prototype.keys",
// can use Symbol.iterator, not implemented in many environments
// "Array.prototype methods / Array.prototype.values",
"Array.prototype methods / Array.prototype.entries",
]
},
"es6.number.is-finite": "Number properties / Number.isFinite",
"es6.number.is-integer": "Number properties / Number.isInteger",
"es6.number.is-safe-integer": "Number properties / Number.isSafeInteger",
"es6.number.is-nan": "Number properties / Number.isNaN",
"es6.number.epsilon": "Number properties / Number.EPSILON",
"es6.number.min-safe-integer": "Number properties / Number.MIN_SAFE_INTEGER",
"es6.number.max-safe-integer": "Number properties / Number.MAX_SAFE_INTEGER",
"es6.math.acosh": "Math methods / Math.acosh",
"es6.math.asinh": "Math methods / Math.asinh",
"es6.math.atanh": "Math methods / Math.atanh",
"es6.math.cbrt": "Math methods / Math.cbrt",
"es6.math.clz32": "Math methods / Math.clz32",
"es6.math.cosh": "Math methods / Math.cosh",
"es6.math.expm1": "Math methods / Math.expm1",
"es6.math.fround": "Math methods / Math.fround",
"es6.math.hypot": "Math methods / Math.hypot",
"es6.math.imul": "Math methods / Math.imul",
"es6.math.log1p": "Math methods / Math.log1p",
"es6.math.log10": "Math methods / Math.log10",
"es6.math.log2": "Math methods / Math.log2",
"es6.math.sign": "Math methods / Math.sign",
"es6.math.sinh": "Math methods / Math.sinh",
"es6.math.tanh": "Math methods / Math.tanh",
"es6.math.trunc": "Math methods / Math.trunc",
};
const es2016 = {
"es7.array.includes": "Array.prototype.includes",
};
const es2017 = {
"es7.object.values": "Object static methods / Object.values",
"es7.object.entries": "Object static methods / Object.entries",
"es7.object.get-own-property-descriptors": "Object static methods / Object.getOwnPropertyDescriptors",
"es7.string.pad-start": "String padding / String.prototype.padStart",
"es7.string.pad-end": "String padding / String.prototype.padEnd",
};
module.exports = Object.assign({}, es2015, es2016, es2017);

View File

@@ -0,0 +1,929 @@
{
"es6.typed.array-buffer": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.data-view": {
"chrome": "5",
"opera": "12",
"edge": "12",
"firefox": "15",
"safari": "5.1",
"node": "0.12",
"ie": "10",
"android": "4",
"ios": "6",
"electron": "1.1"
},
"es6.typed.int8-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.uint8-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.uint8-clamped-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.int16-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.uint16-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.int32-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.uint32-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.float32-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.typed.float64-array": {
"chrome": "51",
"edge": "13",
"firefox": "48",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.map": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.set": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.weak-map": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "9",
"node": "6.5",
"ios": "9",
"opera": "38",
"electron": "1.2"
},
"es6.weak-set": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "9",
"node": "6.5",
"ios": "9",
"opera": "38",
"electron": "1.2"
},
"es6.reflect.apply": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.construct": {
"chrome": "49",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.define-property": {
"chrome": "49",
"edge": "13",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.delete-property": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.get": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.get-own-property-descriptor": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.get-prototype-of": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.has": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.is-extensible": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.own-keys": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.prevent-extensions": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.set": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.reflect.set-prototype-of": {
"chrome": "49",
"edge": "12",
"firefox": "42",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"es6.promise": {
"chrome": "51",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.symbol": {
"chrome": "51",
"firefox": "51",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.object.freeze": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.seal": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.prevent-extensions": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.is-frozen": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.is-sealed": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.is-extensible": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.get-own-property-descriptor": {
"chrome": "44",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.get-prototype-of": {
"chrome": "44",
"edge": "12",
"firefox": "3.5",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"es6.object.keys": {
"chrome": "40",
"edge": "12",
"firefox": "35",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "27",
"electron": "0.21"
},
"es6.object.get-own-property-names": {
"chrome": "40",
"edge": "12",
"firefox": "33",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "27",
"electron": "0.21"
},
"es6.object.assign": {
"chrome": "45",
"edge": "12",
"firefox": "34",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "32",
"electron": "0.35"
},
"es6.object.is": {
"chrome": "19",
"edge": "12",
"firefox": "22",
"safari": "9",
"node": "0.12",
"android": "4.1",
"ios": "9",
"electron": "0.2"
},
"es6.object.set-prototype-of": {
"chrome": "34",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"ie": "11",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.function.name": {
"chrome": "51",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.string.raw": {
"chrome": "41",
"edge": "12",
"firefox": "34",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.string.from-code-point": {
"chrome": "41",
"edge": "12",
"firefox": "29",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.string.code-point-at": {
"chrome": "41",
"edge": "12",
"firefox": "29",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.string.repeat": {
"chrome": "41",
"edge": "12",
"firefox": "24",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.string.starts-with": {
"chrome": "41",
"edge": "12",
"firefox": "29",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.string.ends-with": {
"chrome": "41",
"edge": "12",
"firefox": "29",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.string.includes": {
"chrome": "41",
"edge": "12",
"firefox": "40",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"es6.regexp.flags": {
"chrome": "49",
"firefox": "37",
"safari": "9",
"node": "6",
"ios": "9",
"opera": "36",
"electron": "1"
},
"es6.regexp.match": {
"chrome": "50",
"firefox": "49",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "37",
"electron": "1.1"
},
"es6.regexp.replace": {
"chrome": "50",
"firefox": "49",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "37",
"electron": "1.1"
},
"es6.regexp.split": {
"chrome": "50",
"firefox": "49",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "37",
"electron": "1.1"
},
"es6.regexp.search": {
"chrome": "50",
"firefox": "49",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "37",
"electron": "1.1"
},
"es6.array.from": {
"chrome": "51",
"edge": "15",
"firefox": "36",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"es6.array.of": {
"chrome": "45",
"edge": "12",
"firefox": "25",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "32",
"electron": "0.35"
},
"es6.array.copy-within": {
"chrome": "45",
"edge": "12",
"firefox": "32",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "32",
"electron": "0.35"
},
"es6.array.find": {
"chrome": "45",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "4",
"ios": "8",
"opera": "32",
"electron": "0.35"
},
"es6.array.find-index": {
"chrome": "45",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "4",
"ios": "8",
"opera": "32",
"electron": "0.35"
},
"es6.array.fill": {
"chrome": "45",
"edge": "12",
"firefox": "31",
"safari": "7.1",
"node": "4",
"ios": "8",
"opera": "32",
"electron": "0.35"
},
"es6.array.iterator": {
"chrome": "38",
"edge": "12",
"firefox": "28",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.number.is-finite": {
"chrome": "19",
"edge": "12",
"firefox": "16",
"safari": "9",
"node": "0.12",
"android": "4.1",
"ios": "9",
"electron": "0.2"
},
"es6.number.is-integer": {
"chrome": "34",
"edge": "12",
"firefox": "16",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.is-safe-integer": {
"chrome": "34",
"edge": "12",
"firefox": "32",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.is-nan": {
"chrome": "19",
"edge": "12",
"firefox": "15",
"safari": "9",
"node": "0.12",
"android": "4.1",
"ios": "9",
"electron": "0.2"
},
"es6.number.epsilon": {
"chrome": "34",
"edge": "12",
"firefox": "25",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.min-safe-integer": {
"chrome": "34",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.max-safe-integer": {
"chrome": "34",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.math.acosh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.asinh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.atanh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.cbrt": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.clz32": {
"chrome": "38",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "25",
"electron": "0.2"
},
"es6.math.cosh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.expm1": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.fround": {
"chrome": "38",
"edge": "12",
"firefox": "26",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.hypot": {
"chrome": "38",
"edge": "12",
"firefox": "27",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.imul": {
"chrome": "30",
"edge": "12",
"firefox": "23",
"safari": "7",
"node": "0.12",
"android": "4.4",
"ios": "7",
"opera": "17",
"electron": "0.2"
},
"es6.math.log1p": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.log10": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.log2": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.sign": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "25",
"electron": "0.2"
},
"es6.math.sinh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.tanh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.trunc": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es7.array.includes": {
"chrome": "47",
"edge": "14",
"firefox": "43",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "34",
"electron": "0.36"
},
"es7.object.values": {
"chrome": "54",
"edge": "14",
"firefox": "47",
"safari": "10.1",
"node": "7",
"ios": "10.3",
"opera": "41",
"electron": "1.5"
},
"es7.object.entries": {
"chrome": "54",
"edge": "14",
"firefox": "47",
"safari": "10.1",
"node": "7",
"ios": "10.3",
"opera": "41",
"electron": "1.5"
},
"es7.object.get-own-property-descriptors": {
"chrome": "54",
"edge": "15",
"firefox": "50",
"safari": "10.1",
"node": "7",
"ios": "10.3",
"opera": "41",
"electron": "1.5"
},
"es7.string.pad-start": {
"chrome": "57",
"edge": "15",
"firefox": "48",
"safari": "10",
"node": "8",
"ios": "10",
"opera": "44",
"electron": "1.7"
},
"es7.string.pad-end": {
"chrome": "57",
"edge": "15",
"firefox": "48",
"safari": "10",
"node": "8",
"ios": "10",
"opera": "44",
"electron": "1.7"
}
}

View File

@@ -0,0 +1,133 @@
const es2015 = {
"check-es2015-constants": {
features: [
"const",
],
},
"transform-es2015-arrow-functions": {
features: [
"arrow functions",
],
},
"transform-es2015-block-scoped-functions": {
features: [
"block-level function declaration"
],
},
"transform-es2015-block-scoping": {
features: [
"const",
"let",
],
},
"transform-es2015-classes": {
features: [
"class",
"super",
],
},
"transform-es2015-computed-properties": {
features: [
"object literal extensions / computed properties",
],
},
"transform-es2015-destructuring": {
features: [
"destructuring, assignment",
"destructuring, declarations",
"destructuring, parameters",
],
},
"transform-es2015-duplicate-keys": {
features: [
"miscellaneous / duplicate property names in strict mode",
],
},
"transform-es2015-for-of": {
features: [
"for..of loops",
],
},
"transform-es2015-function-name": {
features: [
"function \"name\" property",
]
},
"transform-es2015-literals": {
features: [
"Unicode code point escapes",
],
},
"transform-es2015-object-super": {
features: [
"super",
],
},
"transform-es2015-parameters": {
features: [
"default function parameters",
"rest parameters",
],
},
"transform-es2015-shorthand-properties": {
features: [
"object literal extensions / shorthand properties",
],
},
"transform-es2015-spread": {
features: [
"spread (...) operator",
],
},
"transform-es2015-sticky-regex": {
features: [
"RegExp \"y\" and \"u\" flags / \"y\" flag, lastIndex",
"RegExp \"y\" and \"u\" flags / \"y\" flag",
],
},
"transform-es2015-template-literals": {
features: [
"template literals",
],
},
"transform-es2015-typeof-symbol": {
features: [
"Symbol / typeof support"
],
},
"transform-es2015-unicode-regex": {
features: [
"RegExp \"y\" and \"u\" flags / \"u\" flag, case folding",
"RegExp \"y\" and \"u\" flags / \"u\" flag, Unicode code point escapes",
"RegExp \"y\" and \"u\" flags / \"u\" flag",
],
},
"transform-regenerator": {
features: [
"generators",
],
}
};
const es2016 = {
"transform-exponentiation-operator": {
features: [
"exponentiation (**) operator",
],
}
};
const es2017 = {
"transform-async-to-generator": {
features: [
"async functions",
],
},
"syntax-trailing-function-commas": {
features: [
"trailing commas in function syntax",
],
}
};
module.exports = Object.assign({}, es2015, es2016, es2017);

View File

@@ -0,0 +1,231 @@
{
"check-es2015-constants": {
"chrome": "49",
"edge": "14",
"firefox": "51",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-arrow-functions": {
"chrome": "47",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "34",
"electron": "0.36"
},
"transform-es2015-block-scoped-functions": {
"chrome": "41",
"edge": "12",
"firefox": "46",
"safari": "10",
"node": "4",
"ie": "11",
"ios": "10",
"opera": "28",
"electron": "0.24"
},
"transform-es2015-block-scoping": {
"chrome": "49",
"edge": "14",
"firefox": "51",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-classes": {
"chrome": "46",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"ios": "10",
"opera": "33",
"electron": "0.36"
},
"transform-es2015-computed-properties": {
"chrome": "44",
"edge": "12",
"firefox": "34",
"safari": "7.1",
"node": "4",
"ios": "8",
"opera": "31",
"electron": "0.31"
},
"transform-es2015-destructuring": {
"chrome": "51",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"transform-es2015-duplicate-keys": {
"chrome": "42",
"edge": "12",
"firefox": "34",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "29",
"electron": "0.27"
},
"transform-es2015-for-of": {
"chrome": "51",
"edge": "15",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"transform-es2015-function-name": {
"chrome": "51",
"firefox": "53",
"safari": "10",
"node": "6.5",
"ios": "10",
"opera": "38",
"electron": "1.2"
},
"transform-es2015-literals": {
"chrome": "44",
"edge": "12",
"firefox": "53",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "31",
"electron": "0.31"
},
"transform-es2015-object-super": {
"chrome": "46",
"edge": "13",
"firefox": "45",
"safari": "10",
"node": "5",
"ios": "10",
"opera": "33",
"electron": "0.36"
},
"transform-es2015-parameters": {
"chrome": "49",
"edge": "14",
"firefox": "53",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-shorthand-properties": {
"chrome": "43",
"edge": "12",
"firefox": "33",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "30",
"electron": "0.29"
},
"transform-es2015-spread": {
"chrome": "46",
"edge": "13",
"firefox": "36",
"safari": "10",
"node": "5",
"ios": "10",
"opera": "33",
"electron": "0.36"
},
"transform-es2015-sticky-regex": {
"chrome": "49",
"edge": "13",
"firefox": "3",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "36",
"electron": "1"
},
"transform-es2015-template-literals": {
"chrome": "41",
"edge": "13",
"firefox": "34",
"safari": "9",
"node": "4",
"ios": "9",
"opera": "28",
"electron": "0.24"
},
"transform-es2015-typeof-symbol": {
"chrome": "38",
"edge": "12",
"firefox": "36",
"safari": "9",
"node": "0.12",
"ios": "9",
"opera": "25",
"electron": "0.2"
},
"transform-es2015-unicode-regex": {
"chrome": "50",
"edge": "13",
"firefox": "46",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "37",
"electron": "1.1"
},
"transform-regenerator": {
"chrome": "50",
"edge": "13",
"firefox": "53",
"safari": "10",
"node": "6",
"ios": "10",
"opera": "37",
"electron": "1.1"
},
"transform-exponentiation-operator": {
"chrome": "52",
"edge": "14",
"firefox": "52",
"safari": "10.1",
"node": "7",
"ios": "10.3",
"opera": "39",
"electron": "1.3"
},
"transform-async-to-generator": {
"chrome": "55",
"edge": "15",
"firefox": "52",
"safari": "10.1",
"node": "7.6",
"ios": "10.3",
"opera": "42",
"electron": "1.6"
},
"syntax-trailing-function-commas": {
"chrome": "58",
"edge": "14",
"firefox": "52",
"safari": "10",
"node": "8",
"ios": "10",
"opera": "45",
"electron": "1.7"
}
}

View File

@@ -0,0 +1,4 @@
"use strict";
exports.__esModule = true;
var defaultWebIncludes = exports.defaultWebIncludes = ["web.timers", "web.immediate", "web.dom.iterable"];

View File

@@ -0,0 +1,194 @@
"use strict";
exports.__esModule = true;
exports.transformIncludesAndExcludes = exports.isPluginRequired = undefined;
exports.default = buildPreset;
var _semver = require("semver");
var _semver2 = _interopRequireDefault(_semver);
var _builtIns = require("../data/built-ins.json");
var _builtIns2 = _interopRequireDefault(_builtIns);
var _defaultIncludes = require("./default-includes");
var _moduleTransformations = require("./module-transformations");
var _moduleTransformations2 = _interopRequireDefault(_moduleTransformations);
var _normalizeOptions = require("./normalize-options.js");
var _normalizeOptions2 = _interopRequireDefault(_normalizeOptions);
var _plugins = require("../data/plugins.json");
var _plugins2 = _interopRequireDefault(_plugins);
var _transformPolyfillRequirePlugin = require("./transform-polyfill-require-plugin");
var _transformPolyfillRequirePlugin2 = _interopRequireDefault(_transformPolyfillRequirePlugin);
var _targetsParser = require("./targets-parser");
var _targetsParser2 = _interopRequireDefault(_targetsParser);
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Determine if a transformation is required
*
* NOTE: This assumes `supportedEnvironments` has already been parsed by `getTargets`
*
* @param {Object} supportedEnvironments An Object containing environment keys and the lowest
* supported version as a value
* @param {Object} plugin An Object containing environment keys and the lowest
* version the feature was implemented in as a value
* @return {Boolean} Whether or not the transformation is required
*/
var isPluginRequired = exports.isPluginRequired = function isPluginRequired(supportedEnvironments, plugin) {
var targetEnvironments = Object.keys(supportedEnvironments);
if (targetEnvironments.length === 0) {
return true;
}
var isRequiredForEnvironments = targetEnvironments.filter(function (environment) {
// Feature is not implemented in that environment
if (!plugin[environment]) {
return true;
}
var lowestImplementedVersion = plugin[environment];
var lowestTargetedVersion = supportedEnvironments[environment];
if (!_semver2.default.valid(lowestTargetedVersion)) {
throw new Error(
// eslint-disable-next-line max-len
"Invalid version passed for target \"" + environment + "\": \"" + lowestTargetedVersion + "\". Versions must be in semver format (major.minor.patch)");
}
return _semver2.default.gt((0, _utils.semverify)(lowestImplementedVersion), lowestTargetedVersion);
});
return isRequiredForEnvironments.length > 0;
};
var hasBeenLogged = false;
var logPlugin = function logPlugin(plugin, targets, list) {
var envList = list[plugin] || {};
var filteredList = Object.keys(targets).reduce(function (a, b) {
if (!envList[b] || _semver2.default.lt(targets[b], (0, _utils.semverify)(envList[b]))) {
a[b] = (0, _utils.prettifyVersion)(targets[b]);
}
return a;
}, {});
var logStr = " " + plugin + " " + JSON.stringify(filteredList);
console.log(logStr);
};
var filterItem = function filterItem(targets, exclusions, list, item) {
var isDefault = _defaultIncludes.defaultWebIncludes.indexOf(item) >= 0;
var notExcluded = exclusions.indexOf(item) === -1;
if (isDefault) return notExcluded;
var isRequired = isPluginRequired(targets, list[item]);
return isRequired && notExcluded;
};
var getBuiltInTargets = function getBuiltInTargets(targets) {
var builtInTargets = (0, _utils._extends)({}, targets);
if (builtInTargets.uglify != null) {
delete builtInTargets.uglify;
}
return builtInTargets;
};
var transformIncludesAndExcludes = exports.transformIncludesAndExcludes = function transformIncludesAndExcludes(opts) {
return {
all: opts,
plugins: opts.filter(function (opt) {
return !opt.match(/^(es\d+|web)\./);
}),
builtIns: opts.filter(function (opt) {
return opt.match(/^(es\d+|web)\./);
})
};
};
function getPlatformSpecificDefaultFor(targets) {
var targetNames = Object.keys(targets);
var isAnyTarget = !targetNames.length;
var isWebTarget = targetNames.some(function (name) {
return name !== "node";
});
return isAnyTarget || isWebTarget ? _defaultIncludes.defaultWebIncludes : [];
}
function buildPreset(context) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var validatedOptions = (0, _normalizeOptions2.default)(opts);
var debug = validatedOptions.debug,
loose = validatedOptions.loose,
moduleType = validatedOptions.moduleType,
spec = validatedOptions.spec,
useBuiltIns = validatedOptions.useBuiltIns;
var targets = (0, _targetsParser2.default)(validatedOptions.targets);
var include = transformIncludesAndExcludes(validatedOptions.include);
var exclude = transformIncludesAndExcludes(validatedOptions.exclude);
var filterPlugins = filterItem.bind(null, targets, exclude.plugins, _plugins2.default);
var transformations = Object.keys(_plugins2.default).filter(filterPlugins).concat(include.plugins);
var polyfills = void 0;
var polyfillTargets = void 0;
if (useBuiltIns) {
polyfillTargets = getBuiltInTargets(targets);
var filterBuiltIns = filterItem.bind(null, polyfillTargets, exclude.builtIns, _builtIns2.default);
polyfills = Object.keys(_builtIns2.default).concat(getPlatformSpecificDefaultFor(polyfillTargets)).filter(filterBuiltIns).concat(include.builtIns);
}
if (debug && !hasBeenLogged) {
hasBeenLogged = true;
console.log("babel-preset-env: `DEBUG` option");
console.log("\nUsing targets:");
console.log(JSON.stringify((0, _utils.prettifyTargets)(targets), null, 2));
console.log("\nModules transform: " + moduleType);
console.log("\nUsing plugins:");
transformations.forEach(function (transform) {
logPlugin(transform, targets, _plugins2.default);
});
if (useBuiltIns && polyfills.length) {
console.log("\nUsing polyfills:");
polyfills.forEach(function (polyfill) {
logPlugin(polyfill, polyfillTargets, _builtIns2.default);
});
}
}
var regenerator = transformations.indexOf("transform-regenerator") >= 0;
var modulePlugin = moduleType !== false && _moduleTransformations2.default[moduleType];
var plugins = [];
// NOTE: not giving spec here yet to avoid compatibility issues when
// babel-plugin-transform-es2015-modules-commonjs gets its spec mode
modulePlugin && plugins.push([require("babel-plugin-" + modulePlugin), { loose: loose }]);
plugins.push.apply(plugins, transformations.map(function (pluginName) {
return [require("babel-plugin-" + pluginName), { spec: spec, loose: loose }];
}));
useBuiltIns && plugins.push([_transformPolyfillRequirePlugin2.default, { polyfills: polyfills, regenerator: regenerator }]);
return {
plugins: plugins
};
}

View File

@@ -0,0 +1,9 @@
"use strict";
exports.__esModule = true;
exports.default = {
"amd": "transform-es2015-modules-amd",
"commonjs": "transform-es2015-modules-commonjs",
"systemjs": "transform-es2015-modules-systemjs",
"umd": "transform-es2015-modules-umd"
};

View File

@@ -0,0 +1,126 @@
"use strict";
exports.__esModule = true;
exports.validateModulesOption = exports.validateSpecOption = exports.validateLooseOption = exports.validateBoolOption = exports.checkDuplicateIncludeExcludes = exports.normalizePluginNames = exports.normalizePluginName = exports.validateIncludesAndExcludes = undefined;
exports.default = normalizeOptions;
var _invariant = require("invariant");
var _invariant2 = _interopRequireDefault(_invariant);
var _builtIns = require("../data/built-ins.json");
var _builtIns2 = _interopRequireDefault(_builtIns);
var _defaultIncludes = require("./default-includes");
var _moduleTransformations = require("./module-transformations");
var _moduleTransformations2 = _interopRequireDefault(_moduleTransformations);
var _plugins = require("../data/plugins.json");
var _plugins2 = _interopRequireDefault(_plugins);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var validIncludesAndExcludes = [].concat(Object.keys(_plugins2.default), Object.keys(_moduleTransformations2.default).map(function (m) {
return _moduleTransformations2.default[m];
}), Object.keys(_builtIns2.default), _defaultIncludes.defaultWebIncludes);
var hasBeenWarned = false;
var validateIncludesAndExcludes = exports.validateIncludesAndExcludes = function validateIncludesAndExcludes() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var type = arguments[1];
(0, _invariant2.default)(Array.isArray(opts), "Invalid Option: The '" + type + "' option must be an Array<String> of plugins/built-ins");
var unknownOpts = [];
opts.forEach(function (opt) {
if (validIncludesAndExcludes.indexOf(opt) === -1) {
unknownOpts.push(opt);
}
});
(0, _invariant2.default)(unknownOpts.length === 0, "Invalid Option: The plugins/built-ins '" + unknownOpts + "' passed to the '" + type + "' option are not\n valid. Please check data/[plugin-features|built-in-features].js in babel-preset-env");
return opts;
};
var normalizePluginName = exports.normalizePluginName = function normalizePluginName(plugin) {
return plugin.replace(/^babel-plugin-/, "");
};
var normalizePluginNames = exports.normalizePluginNames = function normalizePluginNames(plugins) {
return plugins.map(normalizePluginName);
};
var checkDuplicateIncludeExcludes = exports.checkDuplicateIncludeExcludes = function checkDuplicateIncludeExcludes() {
var include = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var exclude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var duplicates = include.filter(function (opt) {
return exclude.indexOf(opt) >= 0;
});
(0, _invariant2.default)(duplicates.length === 0, "Invalid Option: The plugins/built-ins '" + duplicates + "' were found in both the \"include\" and\n \"exclude\" options.");
};
var validateBoolOption = exports.validateBoolOption = function validateBoolOption(name, value, defaultValue) {
if (typeof value === "undefined") {
value = defaultValue;
}
if (typeof value !== "boolean") {
throw new Error("Preset env: '" + name + "' option must be a boolean.");
}
return value;
};
var validateLooseOption = exports.validateLooseOption = function validateLooseOption(looseOpt) {
return validateBoolOption("loose", looseOpt, false);
};
var validateSpecOption = exports.validateSpecOption = function validateSpecOption(specOpt) {
return validateBoolOption("spec", specOpt, false);
};
var validateModulesOption = exports.validateModulesOption = function validateModulesOption() {
var modulesOpt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "commonjs";
(0, _invariant2.default)(modulesOpt === false || Object.keys(_moduleTransformations2.default).indexOf(modulesOpt) > -1, "Invalid Option: The 'modules' option must be either 'false' to indicate no modules, or a\n module type which can be be one of: 'commonjs' (default), 'amd', 'umd', 'systemjs'.");
return modulesOpt;
};
function normalizeOptions(opts) {
// TODO: remove whitelist in favor of include in next major
if (opts.whitelist && !hasBeenWarned) {
console.warn("Deprecation Warning: The \"whitelist\" option has been deprecated in favor of \"include\" to\n match the newly added \"exclude\" option (instead of \"blacklist\").");
hasBeenWarned = true;
}
(0, _invariant2.default)(!(opts.whitelist && opts.include), "Invalid Option: The \"whitelist\" and the \"include\" option are the same and one can be used at\n a time");
if (opts.exclude) {
opts.exclude = normalizePluginNames(opts.exclude);
}
if (opts.whitelist || opts.include) {
opts.include = normalizePluginNames(opts.whitelist || opts.include);
}
checkDuplicateIncludeExcludes(opts.include, opts.exclude);
return {
debug: opts.debug,
exclude: validateIncludesAndExcludes(opts.exclude, "exclude"),
include: validateIncludesAndExcludes(opts.include, "include"),
loose: validateLooseOption(opts.loose),
moduleType: validateModulesOption(opts.modules),
spec: validateSpecOption(opts.spec),
targets: opts.targets,
useBuiltIns: opts.useBuiltIns
};
}

View File

@@ -0,0 +1,139 @@
"use strict";
exports.__esModule = true;
var _browserslist = require("browserslist");
var _browserslist2 = _interopRequireDefault(_browserslist);
var _semver = require("semver");
var _semver2 = _interopRequireDefault(_semver);
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var browserNameMap = {
android: "android",
chrome: "chrome",
and_chr: "chrome",
edge: "edge",
firefox: "firefox",
ie: "ie",
ios_saf: "ios",
safari: "safari"
};
var isBrowsersQueryValid = function isBrowsersQueryValid(browsers) {
return typeof browsers === "string" || Array.isArray(browsers);
};
var semverMin = function semverMin(first, second) {
return first && _semver2.default.lt(first, second) ? first : second;
};
var getLowestVersions = function getLowestVersions(browsers) {
return browsers.reduce(function (all, browser) {
var _browser$split = browser.split(" "),
browserName = _browser$split[0],
browserVersion = _browser$split[1];
var normalizedBrowserName = browserNameMap[browserName];
if (!normalizedBrowserName) {
return all;
}
try {
// Browser version can return as "10.0-10.2"
var splitVersion = browserVersion.split("-")[0];
var parsedBrowserVersion = (0, _utils.semverify)(splitVersion);
all[normalizedBrowserName] = semverMin(all[normalizedBrowserName], parsedBrowserVersion);
} catch (e) {}
return all;
}, {});
};
var outputDecimalWarning = function outputDecimalWarning(decimalTargets) {
if (!decimalTargets || !decimalTargets.length) {
return;
}
console.log("Warning, the following targets are using a decimal version:");
console.log("");
decimalTargets.forEach(function (_ref) {
var target = _ref.target,
value = _ref.value;
return console.log(" " + target + ": " + value);
});
console.log("");
console.log("We recommend using a string for minor/patch versions to avoid numbers like 6.10");
console.log("getting parsed as 6.1, which can lead to unexpected behavior.");
console.log("");
};
var targetParserMap = {
__default: function __default(target, value) {
return [target, (0, _utils.semverify)(value)];
},
// Parse `node: true` and `node: "current"` to version
node: function node(target, value) {
var parsed = value === true || value === "current" ? process.versions.node : (0, _utils.semverify)(value);
return [target, parsed];
},
// Only valid value for Uglify is `true`
uglify: function uglify(target, value) {
return [target, value === true];
}
};
var getTargets = function getTargets() {
var targets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var targetOpts = {};
// Parse browsers target via browserslist
if (isBrowsersQueryValid(targets.browsers)) {
targetOpts = getLowestVersions((0, _browserslist2.default)(targets.browsers));
}
// Parse remaining targets
var parsed = Object.keys(targets).reduce(function (results, target) {
if (target !== "browsers") {
var value = targets[target];
// Warn when specifying minor/patch as a decimal
if (typeof value === "number" && value % 1 !== 0) {
results.decimalWarnings.push({ target: target, value: value });
}
// Check if we have a target parser?
var parser = targetParserMap[target] || targetParserMap.__default;
var _parser = parser(target, value),
parsedTarget = _parser[0],
parsedValue = _parser[1];
if (parsedValue) {
results.targets[parsedTarget] = parsedValue;
}
}
return results;
}, {
targets: targetOpts,
decimalWarnings: []
});
outputDecimalWarning(parsed.decimalWarnings);
return parsed.targets;
};
exports.default = getTargets;

View File

@@ -0,0 +1,87 @@
"use strict";
exports.__esModule = true;
exports.default = function (_ref) {
var t = _ref.types;
function createImportDeclaration(polyfill) {
var declar = t.importDeclaration([], t.stringLiteral(polyfill));
declar._blockHoist = 3;
return declar;
}
function createRequireStatement(polyfill) {
return t.expressionStatement(t.callExpression(t.identifier("require"), [t.stringLiteral(polyfill)]));
}
function isRequire(path) {
return t.isExpressionStatement(path.node) && t.isCallExpression(path.node.expression) && t.isIdentifier(path.node.expression.callee) && path.node.expression.callee.name === "require" && path.node.expression.arguments.length === 1 && t.isStringLiteral(path.node.expression.arguments[0]) && isPolyfillSource(path.node.expression.arguments[0].value);
}
function createImport(polyfill, requireType, core) {
if (core) {
polyfill = "core-js/modules/" + polyfill;
}
if (requireType === "import") {
return createImportDeclaration(polyfill);
} else {
return createRequireStatement(polyfill);
}
}
function createImports(polyfills, requireType, regenerator) {
var imports = polyfills.filter(function (el, i, arr) {
return arr.indexOf(el) === i;
}).map(function (polyfill) {
return createImport(polyfill, requireType, true);
});
return [].concat(imports, [regenerator && createImport("regenerator-runtime/runtime", requireType)]).filter(Boolean);
}
var isPolyfillImport = {
ImportDeclaration: function ImportDeclaration(path, state) {
if (path.node.specifiers.length === 0 && isPolyfillSource(path.node.source.value)) {
this.numPolyfillImports++;
if (this.numPolyfillImports > 1) {
path.remove();
return;
}
path.replaceWithMultiple(createImports(state.opts.polyfills, "import", state.opts.regenerator));
}
},
Program: function Program(path, state) {
var _this = this;
if (!state.opts.polyfills) {
throw path.buildCodeFrameError("\nThere was an issue in \"babel-preset-env\" such that\nthe \"polyfills\" option was not correctly passed\nto the \"transform-polyfill-require\" plugin\n");
}
path.get("body").forEach(function (bodyPath) {
if (isRequire(bodyPath)) {
_this.numPolyfillImports++;
if (_this.numPolyfillImports > 1) {
path.remove();
return;
}
bodyPath.replaceWithMultiple(createImports(state.opts.polyfills, "require", state.opts.regenerator));
}
});
}
};
return {
name: "transform-polyfill-require",
visitor: isPolyfillImport,
pre: function pre() {
this.numPolyfillImports = 0;
}
};
};
function isPolyfillSource(value) {
return value === "babel-polyfill" || value === "core-js";
}

View File

@@ -0,0 +1,74 @@
"use strict";
exports.__esModule = true;
exports.prettifyTargets = exports.prettifyVersion = exports.semverify = exports._extends = undefined;
var _semver = require("semver");
var _semver2 = _interopRequireDefault(_semver);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _extends = exports._extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
// Convert version to a semver value.
// 2.5 -> 2.5.0; 1 -> 1.0.0;
// @flow
var semverify = exports.semverify = function semverify(version) {
if (typeof version === "string" && _semver2.default.valid(version)) {
return version;
}
var split = version.toString().split(".");
while (split.length < 3) {
split.push(0);
}
return split.join(".");
};
var prettifyVersion = exports.prettifyVersion = function prettifyVersion(version) {
if (typeof version !== "string") {
return version;
}
var parts = [_semver2.default.major(version)];
var minor = _semver2.default.minor(version);
var patch = _semver2.default.patch(version);
if (minor || patch) {
parts.push(minor);
}
if (patch) {
parts.push(patch);
}
return parts.join(".");
};
var prettifyTargets = exports.prettifyTargets = function prettifyTargets() {
var targets = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return Object.keys(targets).reduce(function (results, target) {
var value = targets[target];
if (typeof value === "string") {
value = prettifyVersion(value);
}
results[target] = value;
return results;
}, {});
};

View File

@@ -0,0 +1,15 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../browserslist/cli.js" "$@"
ret=$?
else
node "$basedir/../browserslist/cli.js" "$@"
ret=$?
fi
exit $ret

View File

@@ -0,0 +1,17 @@
@ECHO off
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
"%_prog%" "%dp0%\..\browserslist\cli.js" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../browserslist/cli.js" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../browserslist/cli.js" $args
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,288 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 3.2.8
* Add IE 9-5.5 to dead browsers.
* Remove development configs from npm package.
## 3.2.7
* Add Firefox 60 as Firefox ESR.
## 3.2.6
* Add Opera Mini 12 to dead browsers.
* Update docs (by Jamie Kyle).
## 3.2.5
* Fix excluding Opera Mini and other browsers with `all` version.
## 3.2.4
* Resolve shareable config from current working directory.
## 3.2.3
* Fix `package.json` config validation for single string case.
* Fix CLI error reporting.
## 3.2.2
* Add `package.json` config validation.
* Move project to `browserlist` GitHub organization.
## 3.2.1
* Fix error text (by Steve Schrab).
## 3.2
* Add `cover 99%` query (by Vasily Fedoseyev).
* Add `cover 99% in US` query (by Vasily Fedoseyev).
* Add `cover 99% in my stats` query (by Vasily Fedoseyev).
* Add `"my stats"` support to `browserlist.coverage()` (by Vasily Fedoseyev).
## 3.1.2
* Add more clear error on missed browser version.
## 3.1.1
* Fix JSDoc (by Sylvain Pollet-Villard).
## 3.1
* Add `ignoreUnknownVersions` option.
* Fix docs (by Pascal Duez).
## 3.0
* Remove country statistics from client-side build of Browserslist.
* Change `> 1%` to `> 0.5%` in default query.
* Add `not dead` to default query.
* Change default environment to `production` (by Marco Fugaro).
* Add `dead` query support with IE 10 and BlackBerry browser.
* Add multiple environments in one section support (by Evilebot Tnawi).
* Add custom statistics support to `browserlist.coverage()`.
* Fix `path` option check.
## 2.11.3
* Fix for `path: undefined` option.
## 2.11.2
* Remove Node.js specific code from webpack build.
## 2.11.1
* Fix using Browserslist in browser with `path` but without `fs`.
## 2.11
* Add `last 2 years` query support (by James Harris).
## 2.10.2
* Fix Browserify support.
## 2.10.1
* Fix using Browserslist without `process` (by Andrew Patton).
## 2.10
* Add `< 1%` and `<= 1%` queries support (by August Kaiser).
## 2.9.1
* Fix unknown query on trailing spaces in query.
## 2.9
* Add `last Electron versions` and `last Electron major versions` queries
(by Louis Mouhat).
## 2.8
* Add `since 2016-03` and `since 2016-03-20` queries support (by Andrew Blick).
## 2.7
* Add `since 2016` queries support (by Igor Deryabin).
## 2.6.1
* Fix `Path must be a string` error.
## 2.6
* By default load config from current directory in CLI tool.
## 2.5.1
* Allow `@scope/browserlist-config` config name (by Jamie Connolly).
## 2.5
* Add `extends` query (by YellowKirby).
## 2.4.1
* Throw error if `package.json` contain `browserlist` instead of `browserslist`.
## 2.4
* Add `last n major versions` query (by John Sanders).
## 2.3.3
* Fix browsers support.
## 2.3.2
* Fix `> 0` query for browsers with one version (by Nikolay Solovyov).
## 2.3.1
* Reduce library size.
## 2.3
* Add `unreleased versions` and `unreleased Chrome versions` queries.
## 2.2.2
* Fix `Path must be a string` error (by Pieter Beulque).
## 2.2.1
* Fix security issue with regions dynamic `require`.
## 2.2
* Add region usage statistics support (by Clément P).
## 2.1.5
* Remove Firefox 45 from Firefox ESR.
## 2.1.4
* Use both ESR versions when they actual.
## 2.1.3
* Add warning on first exclude query.
## 2.1.2
* Fix non-Node.js environments support.
## 2.1.1
* Fix CLI arguments parsing.
## 2.1
* Add `>= 5%`, `>= 5% in US` and `>= 5% in my stats` queries.
## 2.0
* `last n versions` returns versions for all browsers, not only main browsers.
* Cache file system operations (by Aarni Koskela).
* Use `caniuse-lite` 1 MB instead of `caniuse-db` 7 MB (by Ben Briggs).
* Add `.browserslistrc` config support.
* Add QQ Browser for Android support.
* Add tests for CLI (by Zhulduz Zhankenova).
## 1.7.7
* Update Firefox ESR.
## 1.7.6
* Fix Android Chrome selection.
## 1.7.5
* Fix combining `not` query with country based statistics.
* Fix `--env` argument in CLI (by Tuure Savuoja).
## 1.7.4
* Speed up browser sorting (by Aarni Koskela).
## 1.7.3
* Fix config finding when directory was passed to `path` (by Aarni Koskela).
## 1.7.2
* Fix config finding algorithm (by Aarni Koskela).
## 1.7.1
* Fix unreleased browsers version detection.
## 1.7
* Add `--config` and `--env` arguments to CLI (by Jarek Rencz).
## 1.6
* Convert Electron version to Chrome (by Kilian Valkhof).
* Fix `0` version mistake in Can I Use data.
## 1.5.2
* Fix browser versions ordering (by Marco Massarotto).
## 1.5.1
* Fix error on `package.json` and `browserslist` in same directory.
## 1.5
* Add `package.json` support (by Stepan Kuzmin).
* Add environments support (by Maksim Semenov and openlibser).
* Add `browserslist-stats.json` file support (by Oleh Aloshkin).
* Add `config` option to CLI (by Evilebot Tnawi).
* Add JSDoc.
* Fix tests on Windows (by Anna Stoliar).
* Dont set custom usage statistics globally.
## 1.4
* Add `defaults` keyword.
## 1.3.6
* Add `UCAndroid` alias to `and_uc` (by Evilebot Tnawi).
## 1.3.5
* Fix Opera Mini support. Use `op_mini all`.
## 1.3.4
* Add space-less `>1%` and `>.5%` syntax support (by Andreas Lind).
## 1.3.3
* Clean `0` versions in some country-based requests.
## 1.3.2
* Update Firefox ESR.
## 1.3.1
* Add Safari TP support.
## 1.3
* Add coverage for specific country (by Joshua Wise).
## 1.2
* Add `browserslist.coverage()` method.
* Add `--coverage` and `-c` argument to CLI.
* Add `-v` argument support to CLI.
* Better error handling in CLI.
## 1.1.3
* Fix jspm support (by Sean Anderson).
## 1.1.2
* Fix jspm support (by Sean Anderson).
## 1.1.1
* Fix space-less `>10%` and `>10% in my stats` queries.
* Normalize error messages.
* Remove development files from npm package.
## 1.1
* Added query against custom browser usage data (by Daniel Rey).
## 1.0.1
* Update Firefox ESR (by Rouven Weßling).
## 1.0
* Remove Opera 12.1 from default query.
* Add `not` keyword and exclude browsers by query.
* Add Microsoft Edge support (by Andrey Polischuk).
* Add CLI for debug and non-JS usage (by Luke Horvat).
* Use own class in Browserslist errors.
## 0.5
* Add version ranges `IE 6-9` (by Ben Briggs).
## 0.4
* Add `config` option and `BROWSERSLIST_CONFIG` environment variable support.
* Add symlink config support.
## 0.3.3
* Fix DynJS compatibility (by Nick Howes).
## 0.3.2
* Fix joined versions on versions query (by Vincent De Oliveira).
## 0.3.1
* Fix global variable leak (by Peter Müller).
## 0.3
* Takes queries from `BROWSERSLIST` environment variable.
## 0.2
* Return Can I Use joined versions as `ios_saf 7.0-7.1`.
## 0.1.3
* Better work with Can I Use joined versions like `ios_saf 7.0-7.1`.
* Browserslist now understands `ios_saf 7.0` or `ios_saf 7`.
## 0.1.2
* Do not create global `browserslist` var (by Maxime Thirouin).
## 0.1.1
* Sort browsers by name and version.
## 0.1
* Initial release.

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2014 Andrey Sitnik <andrey@sitnik.ru>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,516 @@
# Browserslist [![Cult Of Martians][cult-img]][cult]
<img align="right" width="120" height="120"
src="./logo.svg" alt="Browserslist logo by Anton Lovchikov">
Library to share target browsers between different front-end tools.
It is used in:
* [Autoprefixer]
* [Babel]
(external config in `package.json` or `browserslist` will be supported in 7.0)
* [postcss-preset-env]
* [eslint-plugin-compat]
* [stylelint-no-unsupported-browser-features]
* [postcss-normalize]
[Browserslist Example] shows how every tool uses Browserslist.
All tools will find target browsers automatically,
when you add the following to `package.json`:
```json
{
"browserslist": [
"> 1%",
"IE 10"
]
}
```
Or in `.browserslistrc` config:
```yaml
# Browsers that we support
> 1%
IE 10 # sorry
```
Developers set browsers list in queries like `last 2 version`
to be free from updating browser versions manually.
Browserslist will use [Can I Use] data for this queries.
Browserslist will take browsers queries from tool option,
`browserslist` config, `.browserslistrc` config,
`browserslist` section in `package.json` or environment variables.
You can test Browserslist queries in [online demo].
[cult-img]: http://cultofmartians.com/assets/badges/badge.svg
[cult]: http://cultofmartians.com/done.html
<a href="https://evilmartians.com/?utm_source=browserslist">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
alt="Sponsored by Evil Martians" width="236" height="54">
</a>
[stylelint-no-unsupported-browser-features]: https://github.com/ismay/stylelint-no-unsupported-browser-features
[eslint-plugin-compat]: https://github.com/amilajack/eslint-plugin-compat
[Browserslist Example]: https://github.com/browserslist/browserslist-example
[postcss-preset-env]: https://github.com/jonathantneal/postcss-preset-env
[postcss-normalize]: https://github.com/jonathantneal/postcss-normalize
[Autoprefixer]: https://github.com/postcss/autoprefixer
[online demo]: http://browserl.ist/
[Can I Use]: http://caniuse.com/
[Babel]: https://github.com/babel/babel/tree/master/packages/babel-preset-env
## Tools
* [`browserslist-ga`] downloads your website browsers statistics
to use it in `> 0.5% in my stats` query.
* [`browserslist-useragent`] checks browser by user agent string
to match Browserslist target browsers query.
* [`browserslist-useragent-ruby`] is a Ruby library to checks browser
by user agent string to match Browserslist.
* [`caniuse-api`] returns browsers which support some specific feature.
* Run `npx browserslist` in your project directory to see projects
target browsers. This CLI tool is built-in and available in any project
with Autoprefixer.
[`browserslist-useragent-ruby`]: https://github.com/browserslist/browserslist-useragent-ruby
[`browserslist-useragent`]: https://github.com/pastelsky/browserslist-useragent
[`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
[`caniuse-api`]: https://github.com/Nyalab/caniuse-api
## Queries
Browserslist will use browsers query from one of this sources:
1. Tool options. For example `browsers` option in Autoprefixer.
2. `BROWSERSLIST` environment variable.
3. `browserslist` config file in current or parent directories.
3. `.browserslistrc` config file in current or parent directories.
4. `browserslist` key in `package.json` file in current or parent directories.
**We recommend this way.**
5. If the above methods did not produce a valid result
Browserslist will use defaults:
`> 0.5%, last 2 versions, Firefox ESR, not dead`.
### Best Practices
* Select browsers directly (`last 2 Chrome versions`) only if you are making
web app for kiosk with one browser. There are a lot browsers on the market.
If you are making general web app you should respect browsers diversity.
* If you want to change the default set of browsers we recommend to combine
`last 1 version`, `not dead` with `> 0.2%` (or `> 1% in US`,
`> 1% in my stats`). Just `last n versions` adds to many dead browsers
and do not add popular old versions. Just `> 0.2%` make popular browsers even
more popular, so we will have a monopoly and stagnation, as we had
with Internet Explorer 6.
* Dont remove browsers just because you dont know them. Opera Mini has
100 million users in Africa and it is more popular in global market,
than Microsoft Edge. Chinese QQ Browsers has more market share than Firefox
and desktop Safari altogether.
### Full List
You can specify the versions by queries (case insensitive):
* `> 5%`: versions selected by global usage statistics.
`>=`, `<` and `<=` work too.
* `> 5% in US`: uses USA usage statistics. It accepts [two-letter country code].
* `> 5% in alt-AS`: uses Asia region usage statistics. List of all region codes
can be found at [`caniuse-lite/data/regions`].
* `> 5% in my stats`: uses [custom usage data].
* `cover 99.5%`: most popular browsers that provide coverage.
* `cover 99.5% in US`: same as above, with [two-letter country code].
* `cover 99.5% in my stats`: uses [custom usage data].
* `extends browserslist-config-mycompany`: take queries from
`browserslist-config-mycompany` npm package.
* `ie 6-8`: selects an inclusive range of versions.
* `Firefox > 20`: versions of Firefox newer than 20.
`>=`, `<` and `<=` work too.
* `iOS 7`: the iOS browser version 7 directly.
* `Firefox ESR`: the latest [Firefox ESR] version.
* `unreleased versions` or `unreleased Chrome versions`:
alpha and beta versions.
* `last 2 major versions` or `last 2 iOS major versions`:
all minor/patch releases of last 2 major versions.
* `since 2015` or `last 2 years`: all versions released since year 2015
(also `since 2015-03` and `since 2015-03-10`).
* `dead`: browsers from `last 2 version` query, but with less than 0.5%
in global usage statistics and without official support or updates
for 24 months. Right now it is `IE 10`, `IE_Mob 10`, `BlackBerry 10`,
`BlackBerry 7`, and `OperaMobile 12.1`.
* `last 2 versions`: the last 2 versions for *each* browser.
* `last 2 Chrome versions`: the last 2 versions of Chrome browser.
* `defaults`: Browserslists default browsers
(`> 0.5%, last 2 versions, Firefox ESR, not dead`).
* `not ie <= 8`: exclude browsers selected by previous queries.
You can add `not ` to any query.
### Debug
Run `npx browserslist` in project directory to see what browsers was selected
by your queries.
```sh
$ npx browserslist
and_chr 61
and_ff 56
and_qq 1.2
and_uc 11.4
android 56
baidu 7.12
bb 10
chrome 62
edge 16
firefox 56
ios_saf 11
opera 48
safari 11
samsung 5
```
### Notes
Browserslist works with separated versions of browsers.
You should avoid queries like `Firefox > 0`.
Multiple criteria are combined as a boolean `OR`. A browser version must match
at least one of the criteria to be selected.
All queries are based on the [Can I Use] support table,
e.g. `last 3 iOS versions` might select `8.4, 9.2, 9.3` (mixed major and minor),
whereas `last 3 Chrome versions` might select `50, 49, 48` (major only).
[`caniuse-lite/data/regions`]: https://github.com/ben-eb/caniuse-lite/tree/master/data/regions
[two-letter country code]: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements
[custom usage data]: #custom-usage-data
[Can I Use]: http://caniuse.com/
### Browsers
Names are case insensitive:
* `Android` for Android WebView.
* `Baidu` for Baidu Browser.
* `BlackBerry` or `bb` for Blackberry browser.
* `Chrome` for Google Chrome.
* `ChromeAndroid` or `and_chr` for Chrome for Android
* `Edge` for Microsoft Edge.
* `Electron` for Electron framework. It will be converted to Chrome version.
* `Explorer` or `ie` for Internet Explorer.
* `ExplorerMobile` or `ie_mob` for Internet Explorer Mobile.
* `Firefox` or `ff` for Mozilla Firefox.
* `FirefoxAndroid` or `and_ff` for Firefox for Android.
* `iOS` or `ios_saf` for iOS Safari.
* `Opera` for Opera.
* `OperaMini` or `op_mini` for Opera Mini.
* `OperaMobile` or `op_mob` for Opera Mobile.
* `QQAndroid` or `and_qq` for QQ Browser for Android.
* `Safari` for desktop Safari.
* `Samsung` for Samsung Internet.
* `UCAndroid` or `and_uc` for UC Browser for Android.
## `package.json`
If you want to reduce config files in project root, you can specify
browsers in `package.json` with `browserslist` key:
```json
{
"private": true,
"dependencies": {
"autoprefixer": "^6.5.4"
},
"browserslist": [
"> 1%",
"IE 10"
]
}
```
## Config File
Browserslist config should be named `.browserslistrc` or `browserslist`
and have browsers queries split by a new line. Comments starts with `#` symbol:
```yaml
# Browsers that we support
> 1%
IE 10 # sorry
```
Browserslist will check config in every directory in `path`.
So, if tool process `app/styles/main.css`, you can put config to root,
`app/` or `app/styles`.
You can specify direct path in `BROWSERSLIST_CONFIG` environment variables.
## Shareable Configs
You can use the following query to reference an exported Browserslist config
from another package:
```json
"browserslist": [
"extends browserslist-config-mycompany"
]
```
For security reasons, external configuration only supports packages that have
the `browserslist-config-` prefix. npm scoped packages are also supported, by
naming or prefixing the module with `@scope/browserslist-config`, such as
`@scope/browserslist-config` or `@scope/browserslist-config-mycompany`.
If you dont accept Browserslist queries from users, you can disable the
validation by using the `dangerousExtend` option:
```js
browserslist(queries, { path, dangerousExtend: true })
```
Because this uses `npm`'s resolution, you can also reference specific files
in a package:
```json
"browserslist": [
"extends browserslist-config-mycompany/desktop",
"extends browserslist-config-mycompany/mobile"
]
```
When writing a shared Browserslist package, just export an array.
`browserslist-config-mycompany/index.js`:
```js
module.exports = [
'> 1%',
'ie 10'
]
```
## Environment Variables
If some tool use Browserslist inside, you can change browsers settings
by [environment variables]:
* `BROWSERSLIST` with browsers queries.
```sh
BROWSERSLIST="> 5%" gulp css
```
* `BROWSERSLIST_CONFIG` with path to config file.
```sh
BROWSERSLIST_CONFIG=./config/browserslist gulp css
```
* `BROWSERSLIST_ENV` with environments string.
```sh
BROWSERSLIST_ENV="development" gulp css
```
* `BROWSERSLIST_STATS` with path to the custom usage data
for `> 1% in my stats` query.
```sh
BROWSERSLIST_STATS=./config/usage_data.json gulp css
```
* `BROWSERSLIST_DISABLE_CACHE` if you want to disable config reading cache.
```sh
BROWSERSLIST_DISABLE_CACHE=1 gulp css
```
[environment variables]: https://en.wikipedia.org/wiki/Environment_variable
## Environments
You can also specify different browser queries for various environments.
Browserslist will choose query according to `BROWSERSLIST_ENV` or `NODE_ENV`
variables. If none of them is declared, Browserslist will firstly look
for `production` queries and then use defaults.
In `package.json`:
```js
"browserslist": {
"production": [
"> 1%",
"ie 10"
],
"development": [
"last 1 chrome version",
"last 1 firefox version"
]
}
```
In `.browserslistrc` config:
```ini
[production staging]
> 1%
ie 10
[development]
last 1 chrome version
last 1 firefox version
```
## Custom Usage Data
If you have a website, you can query against the usage statistics of your site.
[`browserslist-ga`] will ask access to Google Analytics and then generate
`browserslist-stats.json`:
```
npx browserslist-ga
```
Of course, you can generate usage statistics file by any other method.
File format should be like:
```js
{
"ie": {
"6": 0.01,
"7": 0.4,
"8": 1.5
},
"chrome": {
},
}
```
Note that you can query against your custom usage data
while also querying against global or regional data.
For example, the query `> 1% in my stats, > 5% in US, 10%` is permitted.
[`browserslist-ga`]: https://github.com/browserslist/browserslist-ga
[Can I Use]: http://caniuse.com/
## JS API
```js
var browserslist = require('browserslist');
// Your CSS/JS build tool code
var process = function (source, opts) {
var browsers = browserslist(opts.browsers, {
stats: opts.stats,
path: opts.file,
env: opts.env
});
// Your code to add features for selected browsers
}
```
Queries can be a string `"> 1%, IE 10"`
or an array `['> 1%', 'IE 10']`.
If a query is missing, Browserslist will look for a config file.
You can provide a `path` option (that can be a file) to find the config file
relatively to it.
Options:
* `path`: file or a directory path to look for config file. Default is `.`.
* `env`: what environment section use from config. Default is `production`.
* `stats`: custom usage statistics data.
* `config`: path to config if you want to set it manually.
* `ignoreUnknownVersions`: do not throw on direct query (like `ie 12`).
Default is `false.`
* `dangerousExtend`: Disable security checks for `extend` query.
Default is `false.`
For non-JS environment and debug purpose you can use CLI tool:
```sh
browserslist "> 1%, IE 10"
```
## Coverage
You can get total users coverage for selected browsers by JS API:
```js
browserslist.coverage(browserslist('> 1%'))
//=> 81.4
```
```js
browserslist.coverage(browserslist('> 1% in US'), 'US')
//=> 83.1
```
```js
browserslist.coverage(browserslist('> 1% in my stats'), 'my stats')
//=> 83.1
```
```js
browserslist.coverage(browserslist('> 1% in my stats', { stats }), stats)
//=> 82.2
```
Or by CLI:
```sh
$ browserslist --coverage "> 1%"
These browsers account for 81.4% of all users globally
```
```sh
$ browserslist --coverage=US "> 1% in US"
These browsers account for 83.1% of all users in the US
```
```sh
$ browserslist --coverage "> 1% in my stats"
These browsers account for 83.1% of all users in custom statistics
```
```sh
$ browserslist --coverage "> 1% in my stats" --stats=./stats.json
These browsers account for 83.1% of all users in custom statistics
```
## Cache
Browserslist caches the configuration it reads from `package.json` and
`browserslist` files, as well as knowledge about the existence of files,
for the duration of the hosting process.
To clear these caches, use:
```js
browserslist.clearCaches();
```
To disable the caching altogether, set the `BROWSERSLIST_DISABLE_CACHE`
environment variable.

View File

@@ -0,0 +1,35 @@
var BrowserslistError = require('./error')
function noop () { }
module.exports = {
loadQueries: function loadQueries () {
throw new BrowserslistError(
'Sharable configs are not supported in client-side build of Browserslist')
},
getStat: function getStat (opts) {
return opts.stats
},
loadConfig: function loadConfig (opts) {
if (opts.config) {
throw new BrowserslistError(
'Browserslist config are not supported in client-side build')
}
},
loadCountry: function loadCountry () {
throw new BrowserslistError(
'Country statistics is not supported ' +
'in client-side build of Browserslist')
},
parseConfig: noop,
readConfig: noop,
findConfig: noop,
clearCaches: noop
}

View File

@@ -0,0 +1,112 @@
#!/usr/bin/env node
var fs = require('fs')
var browserslist = require('./')
var pkg = require('./package.json')
var args = process.argv.slice(2)
var USAGE = 'Usage:\n' +
' ' + pkg.name + '\n' +
' ' + pkg.name + ' "QUERIES"\n' +
' ' + pkg.name + ' --config="path/to/browserlist/file"\n' +
' ' + pkg.name + ' --coverage "QUERIES"\n' +
' ' + pkg.name + ' --coverage=US "QUERIES"\n' +
' ' + pkg.name + ' --env="environment name defined in config"\n' +
' ' + pkg.name + ' --stats="path/to/browserlist/stats/file"'
function isArg (arg) {
return args.some(function (str) {
return str === arg || str.indexOf(arg + '=') === 0
})
}
function error (msg) {
process.stderr.write(pkg.name + ': ' + msg + '\n')
process.exit(1)
}
if (isArg('--help') || isArg('-h')) {
process.stdout.write(pkg.description + '.\n\n' + USAGE + '\n')
} else if (isArg('--version') || isArg('-v')) {
process.stdout.write(pkg.name + ' ' + pkg.version + '\n')
} else {
var mode = 'browsers'
var opts = { }
var queries
var country
for (var i = 0; i < args.length; i++) {
if (args[i][0] !== '-') {
queries = args[i].replace(/^["']|["']$/g, '')
continue
}
var arg = args[i].split('=')
var name = arg[0]
var value = arg[1]
if (value) value = value.replace(/^["']|["']$/g, '')
if (name === '--config' || name === '-b') {
opts.config = value
} else if (name === '--env' || name === '-e') {
opts.env = value
} else if (name === '--stats' || name === '-s') {
opts.stats = value
} else if (name === '--coverage' || name === '-c') {
mode = 'coverage'
if (value) country = value
} else {
error('Unknown arguments ' + args[i] + '.\n\n' + USAGE)
}
}
var browsers
try {
if (!queries && !opts.config) {
if (browserslist.findConfig(process.cwd())) {
opts.path = process.cwd()
} else {
error(
'Browserslist config was not found. ' +
'Define queries or config path.' +
'\n\n' + USAGE
)
}
}
browsers = browserslist(queries, opts)
} catch (e) {
if (e.name === 'BrowserslistError') {
error(e.message)
} else {
throw e
}
}
if (mode === 'browsers') {
browsers.forEach(function (browser) {
process.stdout.write(browser + '\n')
})
} else {
var stats
if (country) {
stats = country
} else if (opts.stats) {
stats = JSON.parse(fs.readFileSync(opts.stats))
}
var result = browserslist.coverage(browsers, stats)
var round = Math.round(result * 100) / 100.0
var end = 'globally'
if (country && country !== 'global') {
end = 'in the ' + country.toUpperCase()
} else if (opts.stats) {
end = 'in custom statistics'
}
process.stdout.write(
'These browsers account for ' + round + '% of all users ' +
end + '\n')
}
}

View File

@@ -0,0 +1,12 @@
function BrowserslistError (message) {
this.name = 'BrowserslistError'
this.message = message
this.browserslist = true
if (Error.captureStackTrace) {
Error.captureStackTrace(this, BrowserslistError)
}
}
BrowserslistError.prototype = Error.prototype
module.exports = BrowserslistError

View File

@@ -0,0 +1,758 @@
var path = require('path')
var e2c = require('electron-to-chromium/versions')
var agents = require('caniuse-lite/dist/unpacker/agents').agents
var BrowserslistError = require('./error')
var env = require('./node') // Will load browser.js in webpack
var FLOAT_RANGE = /^\d+(\.\d+)?(-\d+(\.\d+)?)*$/
function normalize (versions) {
return versions.filter(function (version) {
return typeof version === 'string'
})
}
function nameMapper (name) {
return function mapName (version) {
return name + ' ' + version
}
}
function getMajor (version) {
return parseInt(version.split('.')[0])
}
function getMajorVersions (released, number) {
if (released.length === 0) return []
var minimum = getMajor(released[released.length - 1]) - parseInt(number) + 1
var selected = []
for (var i = released.length - 1; i >= 0; i--) {
if (minimum > getMajor(released[i])) break
selected.unshift(released[i])
}
return selected
}
function uniq (array) {
var filtered = []
for (var i = 0; i < array.length; i++) {
if (filtered.indexOf(array[i]) === -1) filtered.push(array[i])
}
return filtered
}
// Helpers
function fillUsage (result, name, data) {
for (var i in data) {
result[name + ' ' + i] = data[i]
}
}
function generateFilter (sign, version) {
version = parseFloat(version)
if (sign === '>') {
return function (v) {
return parseFloat(v) > version
}
} else if (sign === '>=') {
return function (v) {
return parseFloat(v) >= version
}
} else if (sign === '<') {
return function (v) {
return parseFloat(v) < version
}
} else {
return function (v) {
return parseFloat(v) <= version
}
}
}
function compareStrings (a, b) {
if (a < b) return -1
if (a > b) return +1
return 0
}
function normalizeVersion (data, version) {
if (data.versions.indexOf(version) !== -1) {
return version
} else if (browserslist.versionAliases[data.name][version]) {
return browserslist.versionAliases[data.name][version]
} else if (data.versions.length === 1) {
return data.versions[0]
} else {
return false
}
}
function filterByYear (since) {
return Object.keys(agents).reduce(function (selected, name) {
var data = byName(name)
if (!data) return selected
var versions = Object.keys(data.releaseDate).filter(function (v) {
return data.releaseDate[v] >= since
})
return selected.concat(versions.map(nameMapper(data.name)))
}, [])
}
function byName (name) {
name = name.toLowerCase()
name = browserslist.aliases[name] || name
return browserslist.data[name]
}
function checkName (name) {
var data = byName(name)
if (!data) throw new BrowserslistError('Unknown browser ' + name)
return data
}
function unknownQuery (query) {
return new BrowserslistError('Unknown browser query `' + query + '`')
}
function resolve (queries, context) {
return queries.reduce(function (result, selection, index) {
selection = selection.trim()
if (selection === '') return result
var isExclude = selection.indexOf('not ') === 0
if (isExclude) {
if (index === 0) {
throw new BrowserslistError(
'Write any browsers query (for instance, `defaults`) ' +
'before `' + selection + '`')
}
selection = selection.slice(4)
}
for (var i = 0; i < QUERIES.length; i++) {
var type = QUERIES[i]
var match = selection.match(type.regexp)
if (match) {
var args = [context].concat(match.slice(1))
var array = type.select.apply(browserslist, args)
if (isExclude) {
array = array.concat(array.map(function (j) {
return j.replace(/\s\S+/, ' 0')
}))
return result.filter(function (j) {
return array.indexOf(j) === -1
})
}
return result.concat(array)
}
}
throw unknownQuery(selection)
}, [])
}
/**
* Return array of browsers by selection queries.
*
* @param {(string|string[])} [queries=browserslist.defaults] Browser queries.
* @param {object} [opts] Options.
* @param {string} [opts.path="."] Path to processed file.
* It will be used to find config files.
* @param {string} [opts.env="production"] Processing environment.
* It will be used to take right
* queries from config file.
* @param {string} [opts.config] Path to config file with queries.
* @param {object} [opts.stats] Custom browser usage statistics
* for "> 1% in my stats" query.
* @param {boolean} [opts.ignoreUnknownVersions=false] Do not throw on unknown
* version in direct query.
* @param {boolean} [opts.dangerousExtend] Disable security checks
* for extend query.
* @return {string[]} Array with browser names in Can I Use.
*
* @example
* browserslist('IE >= 10, IE 8') //=> ['ie 11', 'ie 10', 'ie 8']
*/
function browserslist (queries, opts) {
if (typeof opts === 'undefined') opts = { }
if (typeof opts.path === 'undefined') {
opts.path = path.resolve ? path.resolve('.') : '.'
}
if (typeof queries === 'undefined' || queries === null) {
var config = browserslist.loadConfig(opts)
if (config) {
queries = config
} else {
queries = browserslist.defaults
}
}
if (typeof queries === 'string') {
queries = queries.split(/,\s*/)
}
if (!Array.isArray(queries)) {
throw new BrowserslistError(
'Browser queries must be an array. Got ' + typeof queries + '.')
}
var context = {
ignoreUnknownVersions: opts.ignoreUnknownVersions,
dangerousExtend: opts.dangerousExtend
}
var stats = env.getStat(opts)
if (stats) {
context.customUsage = { }
for (var browser in stats) {
fillUsage(context.customUsage, browser, stats[browser])
}
}
var result = resolve(queries, context).map(function (i) {
var parts = i.split(' ')
var name = parts[0]
var version = parts[1]
if (version === '0') {
return name + ' ' + byName(name).versions[0]
} else {
return i
}
}).sort(function (name1, name2) {
name1 = name1.split(' ')
name2 = name2.split(' ')
if (name1[0] === name2[0]) {
if (FLOAT_RANGE.test(name1[1]) && FLOAT_RANGE.test(name2[1])) {
return parseFloat(name2[1]) - parseFloat(name1[1])
} else {
return compareStrings(name2[1], name1[1])
}
} else {
return compareStrings(name1[0], name2[0])
}
})
return uniq(result)
}
// Will be filled by Can I Use data below
browserslist.data = { }
browserslist.usage = {
global: { },
custom: null
}
// Default browsers query
browserslist.defaults = [
'> 0.5%',
'last 2 versions',
'Firefox ESR',
'not dead'
]
// Browser names aliases
browserslist.aliases = {
fx: 'firefox',
ff: 'firefox',
ios: 'ios_saf',
explorer: 'ie',
blackberry: 'bb',
explorermobile: 'ie_mob',
operamini: 'op_mini',
operamobile: 'op_mob',
chromeandroid: 'and_chr',
firefoxandroid: 'and_ff',
ucandroid: 'and_uc',
qqandroid: 'and_qq'
}
// Aliases to work with joined versions like `ios_saf 7.0-7.1`
browserslist.versionAliases = { }
browserslist.clearCaches = env.clearCaches
browserslist.parseConfig = env.parseConfig
browserslist.readConfig = env.readConfig
browserslist.findConfig = env.findConfig
browserslist.loadConfig = env.loadConfig
/**
* Return browsers market coverage.
*
* @param {string[]} browsers Browsers names in Can I Use.
* @param {string|object} [stats="global"] Which statistics should be used.
* Country code or custom statistics.
* Pass `"my stats"` to load statistics
* from Browserslist files.
*
* @return {number} Total market coverage for all selected browsers.
*
* @example
* browserslist.coverage(browserslist('> 1% in US'), 'US') //=> 83.1
*/
browserslist.coverage = function (browsers, stats) {
var data
if (typeof stats === 'undefined') {
data = browserslist.usage.global
} else if (stats === 'my stats') {
var opts = {}
opts.path = path.resolve ? path.resolve('.') : '.'
var customStats = env.getStat(opts)
if (!customStats) {
throw new BrowserslistError('Custom usage statistics was not provided')
}
data = {}
for (var browser in customStats) {
fillUsage(data, browser, customStats[browser])
}
} else if (typeof stats === 'string') {
if (stats.length > 2) {
stats = stats.toLowerCase()
} else {
stats = stats.toUpperCase()
}
env.loadCountry(browserslist.usage, stats)
data = browserslist.usage[stats]
} else {
if ('dataByBrowser' in stats) {
stats = stats.dataByBrowser
}
data = { }
for (var name in stats) {
for (var version in stats[name]) {
data[name + ' ' + version] = stats[name][version]
}
}
}
return browsers.reduce(function (all, i) {
var usage = data[i]
if (usage === undefined) {
usage = data[i.replace(/ \S+$/, ' 0')]
}
return all + (usage || 0)
}, 0)
}
var QUERIES = [
{
regexp: /^last\s+(\d+)\s+major versions?$/i,
select: function (context, versions) {
return Object.keys(agents).reduce(function (selected, name) {
var data = byName(name)
if (!data) return selected
var array = getMajorVersions(data.released, versions)
array = array.map(nameMapper(data.name))
return selected.concat(array)
}, [])
}
},
{
regexp: /^last\s+(\d+)\s+versions?$/i,
select: function (context, versions) {
return Object.keys(agents).reduce(function (selected, name) {
var data = byName(name)
if (!data) return selected
var array = data.released.slice(-versions)
array = array.map(nameMapper(data.name))
return selected.concat(array)
}, [])
}
},
{
regexp: /^last\s+(\d+)\s+electron\s+major versions?$/i,
select: function (context, versions) {
var validVersions = getMajorVersions(Object.keys(e2c).reverse(), versions)
return validVersions.map(function (i) {
return 'chrome ' + e2c[i]
})
}
},
{
regexp: /^last\s+(\d+)\s+(\w+)\s+major versions?$/i,
select: function (context, versions, name) {
var data = checkName(name)
var validVersions = getMajorVersions(data.released, versions)
return validVersions.map(nameMapper(data.name))
}
},
{
regexp: /^last\s+(\d+)\s+electron\s+versions?$/i,
select: function (context, versions) {
return Object.keys(e2c).reverse().slice(-versions).map(function (i) {
return 'chrome ' + e2c[i]
})
}
},
{
regexp: /^last\s+(\d+)\s+(\w+)\s+versions?$/i,
select: function (context, versions, name) {
var data = checkName(name)
return data.released.slice(-versions).map(nameMapper(data.name))
}
},
{
regexp: /^unreleased\s+versions$/i,
select: function () {
return Object.keys(agents).reduce(function (selected, name) {
var data = byName(name)
if (!data) return selected
var array = data.versions.filter(function (v) {
return data.released.indexOf(v) === -1
})
array = array.map(nameMapper(data.name))
return selected.concat(array)
}, [])
}
},
{
regexp: /^unreleased\s+electron\s+versions?$/i,
select: function () {
return []
}
},
{
regexp: /^unreleased\s+(\w+)\s+versions?$/i,
select: function (context, name) {
var data = checkName(name)
return data.versions.filter(function (v) {
return data.released.indexOf(v) === -1
}).map(nameMapper(data.name))
}
},
{
regexp: /^last\s+(\d+)\s+years?$/i,
select: function (context, years) {
var date = new Date()
var since = date.setFullYear(date.getFullYear() - years) / 1000
return filterByYear(since)
}
},
{
regexp: /^since (\d+)(?:-(\d+))?(?:-(\d+))?$/i,
select: function (context, year, month, date) {
year = parseInt(year)
month = parseInt(month || '01') - 1
date = parseInt(date || '01')
var since = Date.UTC(year, month, date, 0, 0, 0) / 1000
return filterByYear(since)
}
},
{
regexp: /^(>=?|<=?)\s*(\d*\.?\d+)%$/,
select: function (context, sign, popularity) {
popularity = parseFloat(popularity)
var usage = browserslist.usage.global
return Object.keys(usage).reduce(function (result, version) {
if (sign === '>') {
if (usage[version] > popularity) {
result.push(version)
}
} else if (sign === '<') {
if (usage[version] < popularity) {
result.push(version)
}
} else if (sign === '<=') {
if (usage[version] <= popularity) {
result.push(version)
}
} else if (usage[version] >= popularity) {
result.push(version)
}
return result
}, [])
}
},
{
regexp: /^(>=?|<=?)\s*(\d*\.?\d+)%\s+in\s+my\s+stats$/,
select: function (context, sign, popularity) {
popularity = parseFloat(popularity)
if (!context.customUsage) {
throw new BrowserslistError('Custom usage statistics was not provided')
}
var usage = context.customUsage
return Object.keys(usage).reduce(function (result, version) {
if (sign === '>') {
if (usage[version] > popularity) {
result.push(version)
}
} else if (sign === '<') {
if (usage[version] < popularity) {
result.push(version)
}
} else if (sign === '<=') {
if (usage[version] <= popularity) {
result.push(version)
}
} else if (usage[version] >= popularity) {
result.push(version)
}
return result
}, [])
}
},
{
regexp: /^(>=?|<=?)\s*(\d*\.?\d+)%\s+in\s+((alt-)?\w\w)$/,
select: function (context, sign, popularity, place) {
popularity = parseFloat(popularity)
if (place.length === 2) {
place = place.toUpperCase()
} else {
place = place.toLowerCase()
}
env.loadCountry(browserslist.usage, place)
var usage = browserslist.usage[place]
return Object.keys(usage).reduce(function (result, version) {
if (sign === '>') {
if (usage[version] > popularity) {
result.push(version)
}
} else if (sign === '<') {
if (usage[version] < popularity) {
result.push(version)
}
} else if (sign === '<=') {
if (usage[version] <= popularity) {
result.push(version)
}
} else if (usage[version] >= popularity) {
result.push(version)
}
return result
}, [])
}
},
{
regexp: /^cover\s+(\d*\.?\d+)%(\s+in\s+(my\s+stats|(alt-)?\w\w))?$/,
select: function (context, coverage, statMode) {
coverage = parseFloat(coverage)
var usage = browserslist.usage.global
if (statMode) {
if (statMode.match(/^\s+in\s+my\s+stats$/)) {
if (!context.customUsage) {
throw new BrowserslistError(
'Custom usage statistics was not provided'
)
}
usage = context.customUsage
} else {
var match = statMode.match(/\s+in\s+((alt-)?\w\w)/)
var place = match[1]
if (place.length === 2) {
place = place.toUpperCase()
} else {
place = place.toLowerCase()
}
env.loadCountry(browserslist.usage, place)
usage = browserslist.usage[place]
}
}
var versions = Object.keys(usage).sort(function (a, b) {
return usage[b] - usage[a]
})
var coveraged = 0
var result = []
var version
for (var i = 0; i <= versions.length; i++) {
version = versions[i]
if (usage[version] === 0) break
coveraged += usage[version]
result.push(version)
if (coveraged >= coverage) break
}
return result
}
},
{
regexp: /^electron\s+([\d.]+)\s*-\s*([\d.]+)$/i,
select: function (context, from, to) {
if (!e2c[from]) {
throw new BrowserslistError('Unknown version ' + from + ' of electron')
}
if (!e2c[to]) {
throw new BrowserslistError('Unknown version ' + to + ' of electron')
}
from = parseFloat(from)
to = parseFloat(to)
return Object.keys(e2c).filter(function (i) {
var parsed = parseFloat(i)
return parsed >= from && parsed <= to
}).map(function (i) {
return 'chrome ' + e2c[i]
})
}
},
{
regexp: /^(\w+)\s+([\d.]+)\s*-\s*([\d.]+)$/i,
select: function (context, name, from, to) {
var data = checkName(name)
from = parseFloat(normalizeVersion(data, from) || from)
to = parseFloat(normalizeVersion(data, to) || to)
function filter (v) {
var parsed = parseFloat(v)
return parsed >= from && parsed <= to
}
return data.released.filter(filter).map(nameMapper(data.name))
}
},
{
regexp: /^electron\s*(>=?|<=?)\s*([\d.]+)$/i,
select: function (context, sign, version) {
return Object.keys(e2c)
.filter(generateFilter(sign, version))
.map(function (i) {
return 'chrome ' + e2c[i]
})
}
},
{
regexp: /^(\w+)\s*(>=?|<=?)\s*([\d.]+)$/,
select: function (context, name, sign, version) {
var data = checkName(name)
var alias = browserslist.versionAliases[data.name][version]
if (alias) {
version = alias
}
return data.released
.filter(generateFilter(sign, version))
.map(function (v) {
return data.name + ' ' + v
})
}
},
{
regexp: /^(firefox|ff|fx)\s+esr$/i,
select: function () {
return ['firefox 52', 'firefox 60']
}
},
{
regexp: /(operamini|op_mini)\s+all/i,
select: function () {
return ['op_mini all']
}
},
{
regexp: /^electron\s+([\d.]+)$/i,
select: function (context, version) {
var chrome = e2c[version]
if (!chrome) {
throw new BrowserslistError(
'Unknown version ' + version + ' of electron')
}
return ['chrome ' + chrome]
}
},
{
regexp: /^(\w+)\s+(tp|[\d.]+)$/i,
select: function (context, name, version) {
if (/^tp$/i.test(version)) version = 'TP'
var data = checkName(name)
var alias = normalizeVersion(data, version)
if (alias) {
version = alias
} else {
if (version.indexOf('.') === -1) {
alias = version + '.0'
} else {
alias = version.replace(/\.0$/, '')
}
alias = normalizeVersion(data, alias)
if (alias) {
version = alias
} else if (context.ignoreUnknownVersions) {
return []
} else {
throw new BrowserslistError(
'Unknown version ' + version + ' of ' + name)
}
}
return [data.name + ' ' + version]
}
},
{
regexp: /^extends (.+)$/i,
select: function (context, name) {
return resolve(env.loadQueries(context, name), context)
}
},
{
regexp: /^defaults$/i,
select: function () {
return browserslist(browserslist.defaults)
}
},
{
regexp: /^dead$/i,
select: function (context) {
var dead = ['ie <= 10', 'ie_mob <= 10', 'bb <= 10', 'op_mob <= 12.1']
return resolve(dead, context)
}
},
{
regexp: /^(\w+)$/i,
select: function (context, name) {
if (byName(name)) {
throw new BrowserslistError(
'Specify versions in Browserslist query for browser ' + name)
} else {
throw unknownQuery(name)
}
}
}
];
// Get and convert Can I Use data
(function () {
for (var name in agents) {
var browser = agents[name]
browserslist.data[name] = {
name: name,
versions: normalize(agents[name].versions),
released: normalize(agents[name].versions.slice(0, -3)),
releaseDate: agents[name].release_date
}
fillUsage(browserslist.usage.global, name, browser.usage_global)
browserslist.versionAliases[name] = { }
for (var i = 0; i < browser.versions.length; i++) {
var full = browser.versions[i]
if (!full) continue
if (full.indexOf('-') !== -1) {
var interval = full.split('-')
for (var j = 0; j < interval.length; j++) {
browserslist.versionAliases[name][interval[j]] = full
}
}
}
}
}())
module.exports = browserslist

View File

@@ -0,0 +1,262 @@
var region = require('caniuse-lite/dist/unpacker/region').default
var path = require('path')
var fs = require('fs')
var BrowserslistError = require('./error')
var IS_SECTION = /^\s*\[(.+)\]\s*$/
var CONFIG_PATTERN = /^browserslist-config-/
var SCOPED_CONFIG__PATTERN = /@[^./]+\/browserslist-config(-|$)/
var FORMAT = 'Browserslist config should be a string or an array ' +
'of strings with browser queries'
var filenessCache = { }
var configCache = { }
function checkExtend (name) {
var use = ' Use `dangerousExtend` option to disable.'
if (!CONFIG_PATTERN.test(name) && !SCOPED_CONFIG__PATTERN.test(name)) {
throw new BrowserslistError(
'Browserslist config needs `browserslist-config-` prefix. ' + use)
}
if (name.indexOf('.') !== -1) {
throw new BrowserslistError(
'`.` not allowed in Browserslist config name. ' + use)
}
if (name.indexOf('node_modules') !== -1) {
throw new BrowserslistError(
'`node_modules` not allowed in Browserslist config.' + use)
}
}
function isFile (file) {
if (file in filenessCache) {
return filenessCache[file]
}
var result = fs.existsSync(file) && fs.statSync(file).isFile()
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
filenessCache[file] = result
}
return result
}
function eachParent (file, callback) {
var loc = path.resolve(file)
do {
var result = callback(loc)
if (typeof result !== 'undefined') return result
} while (loc !== (loc = path.dirname(loc)))
return undefined
}
function check (section) {
if (Array.isArray(section)) {
for (var i = 0; i < section.length; i++) {
if (typeof section[i] !== 'string') {
throw new BrowserslistError(FORMAT)
}
}
} else if (typeof section !== 'string') {
throw new BrowserslistError(FORMAT)
}
}
function pickEnv (config, opts) {
if (typeof config !== 'object') return config
var name
if (typeof opts.env === 'string') {
name = opts.env
} else if (process.env.BROWSERSLIST_ENV) {
name = process.env.BROWSERSLIST_ENV
} else if (process.env.NODE_ENV) {
name = process.env.NODE_ENV
} else {
name = 'production'
}
return config[name] || config.defaults
}
function parsePackage (file) {
var config = JSON.parse(fs.readFileSync(file))
if (config.browserlist && !config.browserslist) {
throw new BrowserslistError(
'`browserlist` key instead of `browserslist` in ' + file)
}
var list = config.browserslist
if (Array.isArray(list)) {
list = { defaults: list }
}
for (var i in list) {
check(list[i])
}
return list
}
module.exports = {
loadQueries: function loadQueries (context, name) {
if (!context.dangerousExtend) checkExtend(name)
// eslint-disable-next-line security/detect-non-literal-require
var queries = require(require.resolve(name, { paths: ['.'] }))
if (!Array.isArray(queries)) {
throw new BrowserslistError(
'`' + name + '` config exports not an array of queries')
}
return queries
},
getStat: function getStat (opts) {
var stats
if (opts.stats) {
stats = opts.stats
} else if (process.env.BROWSERSLIST_STATS) {
stats = process.env.BROWSERSLIST_STATS
} else if (opts.path && path.resolve && fs.existsSync) {
stats = eachParent(opts.path, function (dir) {
var file = path.join(dir, 'browserslist-stats.json')
return isFile(file) ? file : undefined
})
}
if (typeof stats === 'string') {
try {
stats = JSON.parse(fs.readFileSync(stats))
} catch (e) {
throw new BrowserslistError('Can\'t read ' + stats)
}
}
if (stats && 'dataByBrowser' in stats) {
stats = stats.dataByBrowser
}
return stats
},
loadConfig: function loadConfig (opts) {
if (process.env.BROWSERSLIST) {
return process.env.BROWSERSLIST
} else if (opts.config || process.env.BROWSERSLIST_CONFIG) {
var file = opts.config || process.env.BROWSERSLIST_CONFIG
if (path.basename(file) === 'package.json') {
return pickEnv(parsePackage(file), opts)
} else {
return pickEnv(module.exports.readConfig(file), opts)
}
} else if (opts.path) {
return pickEnv(module.exports.findConfig(opts.path), opts)
} else {
return undefined
}
},
loadCountry: function loadCountry (usage, country) {
var code = country.replace(/[^\w-]/g, '')
if (!usage[code]) {
// eslint-disable-next-line security/detect-non-literal-require
var compressed = require('caniuse-lite/data/regions/' + code + '.js')
var data = region(compressed)
usage[country] = { }
for (var i in data) {
for (var j in data[i]) {
usage[country][i + ' ' + j] = data[i][j]
}
}
}
},
parseConfig: function parseConfig (string) {
var result = { defaults: [] }
var sections = ['defaults']
string.toString()
.replace(/#[^\n]*/g, '')
.split(/\n/)
.map(function (line) {
return line.trim()
})
.filter(function (line) {
return line !== ''
})
.forEach(function (line) {
if (IS_SECTION.test(line)) {
sections = line.match(IS_SECTION)[1].trim().split(' ')
sections.forEach(function (section) {
if (result[section]) {
throw new BrowserslistError(
'Dublicate section ' + section + ' in Browserslist config')
}
result[section] = []
})
} else {
sections.forEach(function (section) {
result[section].push(line)
})
}
})
return result
},
readConfig: function readConfig (file) {
if (!isFile(file)) {
throw new BrowserslistError('Can\'t read ' + file + ' config')
}
return module.exports.parseConfig(fs.readFileSync(file))
},
findConfig: function findConfig (from) {
from = path.resolve(from)
var cacheKey = isFile(from) ? path.dirname(from) : from
if (cacheKey in configCache) {
return configCache[cacheKey]
}
var resolved = eachParent(from, function (dir) {
var config = path.join(dir, 'browserslist')
var pkg = path.join(dir, 'package.json')
var rc = path.join(dir, '.browserslistrc')
var pkgBrowserslist
if (isFile(pkg)) {
try {
pkgBrowserslist = parsePackage(pkg)
} catch (e) {
if (e.name === 'BrowserslistError') throw e
console.warn(
'[Browserslist] Could not parse ' + pkg + '. Ignoring it.')
}
}
if (isFile(config) && pkgBrowserslist) {
throw new BrowserslistError(
dir + ' contains both browserslist and package.json with browsers')
} else if (isFile(rc) && pkgBrowserslist) {
throw new BrowserslistError(
dir + ' contains both .browserslistrc and package.json with browsers')
} else if (isFile(config) && isFile(rc)) {
throw new BrowserslistError(
dir + ' contains both .browserslistrc and browserslist')
} else if (isFile(config)) {
return module.exports.readConfig(config)
} else if (isFile(rc)) {
return module.exports.readConfig(rc)
} else {
return pkgBrowserslist
}
})
if (!process.env.BROWSERSLIST_DISABLE_CACHE) {
configCache[cacheKey] = resolved
}
return resolved
},
clearCaches: function clearCaches () {
filenessCache = { }
configCache = { }
}
}

View File

@@ -0,0 +1,99 @@
{
"_from": "browserslist@^3.2.6",
"_id": "browserslist@3.2.8",
"_inBundle": false,
"_integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==",
"_location": "/babel-preset-env/browserslist",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "browserslist@^3.2.6",
"name": "browserslist",
"escapedName": "browserslist",
"rawSpec": "^3.2.6",
"saveSpec": null,
"fetchSpec": "^3.2.6"
},
"_requiredBy": [
"/babel-preset-env"
],
"_resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz",
"_shasum": "b0005361d6471f0f5952797a76fc985f1f978fc6",
"_spec": "browserslist@^3.2.6",
"_where": "D:\\developments\\teaser-inertia\\nova-components\\NovaLeader\\node_modules\\babel-preset-env",
"author": {
"name": "Andrey Sitnik",
"email": "andrey@sitnik.ru"
},
"bin": {
"browserslist": "cli.js"
},
"browser": {
"./node.js": "./browser.js",
"path": false
},
"bugs": {
"url": "https://github.com/browserslist/browserslist/issues"
},
"bundleDependencies": false,
"dependencies": {
"caniuse-lite": "^1.0.30000844",
"electron-to-chromium": "^1.3.47"
},
"deprecated": false,
"description": "Share target browsers between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
"devDependencies": {
"cross-spawn": "^6.0.5",
"eslint": "^4.19.1",
"eslint-ci": "^0.1.1",
"eslint-config-logux": "^22.1.0",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-es5": "^1.3.1",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jest": "^21.15.1",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^3.1.0",
"fs-extra": "^5.0.0",
"jest": "^22.4.4",
"lint-staged": "^7.1.2",
"pre-commit": "^1.1.3",
"size-limit": "^0.18.0",
"yaspeller-ci": "^1.0.0"
},
"homepage": "https://github.com/browserslist/browserslist#readme",
"jest": {
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"statements": 100
}
},
"modulePathIgnorePatterns": [
"<rootDir>/test/fixtures"
]
},
"keywords": [
"caniuse",
"browsers",
"target"
],
"license": "MIT",
"name": "browserslist",
"pre-commit": [
"lint-staged"
],
"repository": {
"type": "git",
"url": "git+https://github.com/browserslist/browserslist.git"
},
"scripts": {
"lint": "eslint-ci *.js test/*.js benchmark/*.js",
"lint-staged": "lint-staged",
"spellcheck": "yaspeller-ci README.md CHANGELOG.md",
"test": "jest --coverage && yarn lint && yarn spellcheck && size-limit"
},
"version": "3.2.8"
}

View File

@@ -0,0 +1,139 @@
{
"_from": "babel-preset-env@^1.5.1",
"_id": "babel-preset-env@1.7.0",
"_inBundle": false,
"_integrity": "sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==",
"_location": "/babel-preset-env",
"_phantomChildren": {
"caniuse-lite": "1.0.30001228",
"electron-to-chromium": "1.3.727"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "babel-preset-env@^1.5.1",
"name": "babel-preset-env",
"escapedName": "babel-preset-env",
"rawSpec": "^1.5.1",
"saveSpec": null,
"fetchSpec": "^1.5.1"
},
"_requiredBy": [
"/laravel-mix"
],
"_resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz",
"_shasum": "dea79fa4ebeb883cd35dab07e260c1c9c04df77a",
"_spec": "babel-preset-env@^1.5.1",
"_where": "D:\\developments\\teaser-inertia\\nova-components\\NovaLeader\\node_modules\\laravel-mix",
"author": {
"name": "Henry Zhu",
"email": "hi@henryzoo.com"
},
"babel": {
"presets": [
[
"env",
{
"loose": true
}
]
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
},
"bugs": {
"url": "https://github.com/babel/babel-preset-env/issues"
},
"bundleDependencies": false,
"dependencies": {
"babel-plugin-check-es2015-constants": "^6.22.0",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
"babel-plugin-transform-async-to-generator": "^6.22.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0",
"babel-plugin-transform-es2015-block-scoping": "^6.23.0",
"babel-plugin-transform-es2015-classes": "^6.23.0",
"babel-plugin-transform-es2015-computed-properties": "^6.22.0",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-es2015-duplicate-keys": "^6.22.0",
"babel-plugin-transform-es2015-for-of": "^6.23.0",
"babel-plugin-transform-es2015-function-name": "^6.22.0",
"babel-plugin-transform-es2015-literals": "^6.22.0",
"babel-plugin-transform-es2015-modules-amd": "^6.22.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.23.0",
"babel-plugin-transform-es2015-modules-systemjs": "^6.23.0",
"babel-plugin-transform-es2015-modules-umd": "^6.23.0",
"babel-plugin-transform-es2015-object-super": "^6.22.0",
"babel-plugin-transform-es2015-parameters": "^6.23.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.22.0",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-es2015-sticky-regex": "^6.22.0",
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
"babel-plugin-transform-es2015-typeof-symbol": "^6.23.0",
"babel-plugin-transform-es2015-unicode-regex": "^6.22.0",
"babel-plugin-transform-exponentiation-operator": "^6.22.0",
"babel-plugin-transform-regenerator": "^6.22.0",
"browserslist": "^3.2.6",
"invariant": "^2.2.2",
"semver": "^5.3.0"
},
"deprecated": false,
"description": "A Babel preset for each environment.",
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-eslint": "^7.1.1",
"babel-helper-fixtures": "^6.22.0",
"babel-helper-plugin-test-runner": "^6.22.0",
"babel-plugin-istanbul": "^3.1.2",
"babel-preset-env": "^1.4.0",
"babel-register": "^6.23.0",
"chai": "^3.5.0",
"codecov": "^1.0.1",
"compat-table": "github:kangax/compat-table#957f1ff15972e8fb2892a172f985e9af27bf1c75",
"electron-to-chromium": "^1.3.11",
"eslint": "^3.17.1",
"eslint-config-babel": "^6.0.0",
"eslint-plugin-flowtype": "^2.29.1",
"fs-extra": "~2.0.0",
"lodash": "^4.17.4",
"mocha": "^3.2.0",
"nyc": "^10.1.2",
"rimraf": "^2.6.1"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "babel-preset-env",
"nyc": {
"all": true,
"include": [
"src/*.js"
],
"instrument": false,
"sourceMap": false
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel-preset-env.git"
},
"scripts": {
"build": "rimraf lib && babel src -d lib",
"build-data": "node ./scripts/build-data.js",
"changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'",
"coverage": "BABEL_ENV=test nyc npm run test",
"coverage-ci": "nyc report --reporter=json && codecov -f coverage/coverage-final.json",
"dev": "babel -w src -d lib",
"fix": "eslint . --fix",
"lint": "eslint .",
"prepublish": "npm run build",
"test": "npm run build && npm run test-only",
"test-ci": "nyc npm run test",
"test-only": "mocha ./test --compilers js:babel-register -t 10000"
},
"version": "1.7.0"
}