This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+13
View File
@@ -0,0 +1,13 @@
coverage
src
test
node_modules
scripts
.eslintignore
.travis.yml
codecov.yml
yarn.lock
.nyc_output
.vscode
.eslintrc
babel-preset-env-*.tgz
+626
View File
@@ -0,0 +1,626 @@
# Changelog
## 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)
+93
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.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 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.
+404
View File
@@ -0,0 +1,404 @@
# 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 can automatically determine the Babel plugins and polyfills you need based on your supported environments.
```sh
npm install babel-preset-env --save-dev
```
```json
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]
]
}
```
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 4, 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": parseFloat(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`
`number | true`
UglifyJS does not currently support any ES6 syntax, so if you are using Uglify to minify your code, targeting later browsers may cause Uglify to throw syntax errors.
To prevent these errors - specify the uglify option, which will enable all plugins and, as a result, fully compile your code to ES5. However, the `useBuiltIns` option will still work as before, and only include the polyfills that your target(s) need.
> NOTE: Uglify has a work-in-progress "Harmony" branch to address the lack of ES6 support, but it is not yet stable. You can follow its progress in [UglifyJS2 issue #448](https://github.com/mishoo/UglifyJS2/issues/448). If you require an alternative minifier which _does_ support ES6 syntax, we recommend using [Babili](https://github.com/babel/babili).
### `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)
- ?
+181
View File
@@ -0,0 +1,181 @@
// 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.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);
+850
View File
@@ -0,0 +1,850 @@
{
"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.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",
"android": "5",
"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",
"android": "5.1",
"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",
"android": "5",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.is-safe-integer": {
"chrome": "34",
"edge": "12",
"firefox": "32",
"safari": "9",
"node": "0.12",
"android": "5",
"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",
"android": "5",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.min-safe-integer": {
"chrome": "34",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"android": "5",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.number.max-safe-integer": {
"chrome": "34",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"android": "5",
"ios": "9",
"opera": "21",
"electron": "0.2"
},
"es6.math.acosh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.asinh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.atanh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.cbrt": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.clz32": {
"chrome": "38",
"edge": "12",
"firefox": "31",
"safari": "9",
"node": "0.12",
"android": "5.1",
"ios": "9",
"opera": "25",
"electron": "0.2"
},
"es6.math.cosh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.expm1": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.fround": {
"chrome": "38",
"edge": "12",
"firefox": "26",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.hypot": {
"chrome": "38",
"edge": "12",
"firefox": "27",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"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",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.log10": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.log2": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.sign": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "9",
"node": "0.12",
"android": "5.1",
"ios": "9",
"opera": "25",
"electron": "0.2"
},
"es6.math.sinh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.tanh": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"ios": "8",
"opera": "25",
"electron": "0.2"
},
"es6.math.trunc": {
"chrome": "38",
"edge": "12",
"firefox": "25",
"safari": "7.1",
"node": "0.12",
"android": "5.1",
"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",
"ios": "10",
"opera": "44",
"electron": "1.7"
},
"es7.string.pad-end": {
"chrome": "57",
"edge": "15",
"firefox": "48",
"safari": "10",
"ios": "10",
"opera": "44",
"electron": "1.7"
}
}
+130
View File
@@ -0,0 +1,130 @@
module.exports = {
// 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",
],
},
// es2016
"transform-exponentiation-operator": {
features: [
"exponentiation (**) operator",
],
},
// es2017
"transform-async-to-generator": {
features: [
"async functions",
],
},
"syntax-trailing-function-commas": {
features: [
"trailing commas in function syntax",
],
}
};
+232
View File
@@ -0,0 +1,232 @@
{
"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",
"edge": "15",
"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",
"android": "5.1",
"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",
"ios": "10",
"opera": "45",
"electron": "1.7"
}
}
+4
View File
@@ -0,0 +1,4 @@
"use strict";
exports.__esModule = true;
var defaultWebIncludes = exports.defaultWebIncludes = ["web.timers", "web.immediate", "web.dom.iterable"];
+194
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
};
}
+9
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"
};
+126
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 _pluginFeatures = require("../data/plugin-features");
var _pluginFeatures2 = _interopRequireDefault(_pluginFeatures);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var validIncludesAndExcludes = [].concat(Object.keys(_pluginFeatures2.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
};
}
+138
View File
@@ -0,0 +1,138 @@
"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",
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;
+87
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";
}
+74
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;
}, {});
};
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) 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
+7
View File
@@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\browserslist\cli.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\browserslist\cli.js" %*
)
+158
View File
@@ -0,0 +1,158 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 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.
+20
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.
+357
View File
@@ -0,0 +1,357 @@
# Browserslist
<img align="right" width="100" height="100"
src="http://ai.github.io/browserslist/logo.svg"
title="Browserslist logo by Anton Lovchikov">
Library to share supported browsers list between different front-end tools.
It is used in:
* [Autoprefixer]
* [babel-env-preset] (no config support, only tool option)
* [eslint-plugin-compat]
* [stylelint-no-unsupported-browser-features]
* [postcss-normalize]
All tools that rely on Browserslist will find its config automatically,
when you add the following to `package.json`:
```json
{
"browserslist": [
"> 1%",
"last 2 versions"
]
}
```
Or in `.browserslistrc` config:
```yaml
# Browsers that we support
> 1%
Last 2 versions
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].
<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
[babel-env-preset]: https://github.com/babel/babel-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/
## 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.
5. If the above methods did not produce a valid result
Browserslist will use defaults: `> 1%, last 2 versions, Firefox ESR`.
We recommend to write queries in `package.json`.
You can specify the versions by queries (case insensitive):
* `last 2 versions`: the last 2 versions for each browser.
* `last 2 Chrome versions`: the last 2 versions of Chrome browser.
* `> 5%` or `>= 5%`: versions selected by global usage statistics.
* `> 5% in US`: uses USA usage statistics. It accepts [two-letter country code].
* `> 5% in my stats`: uses [custom usage data].
* `ie 6-8`: selects an inclusive range of versions.
* `Firefox > 20`: versions of Firefox newer than 20.
* `Firefox >= 20`: versions of Firefox newer than or equal to 20.
* `Firefox < 20`: versions of Firefox less than 20.
* `Firefox <= 20`: versions of Firefox less than or equal to 20.
* `Firefox ESR`: the latest [Firefox ESR] version.
* `iOS 7`: the iOS browser version 7 directly.
* `not ie <= 8`: exclude browsers selected before by previous queries.
You can add `not ` to any query.
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).
[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.
* `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.
### Electron
[`electron-to-chromium`](https://www.npmjs.com/package/electron-to-chromium)
could return a compatible Browserslist query for your (major) Electron version:
```js
const e2c = require('electron-to-chromium')
autoprefixer({
browsers: e2c.electronToBrowserList('1.4') //=> "Chrome >= 53"
})
```
## `package.json`
If you want to reduce config files in project root, you can specify
browsers in `package.json` with `browserslist` key:
```js
{
"private": true,
"dependencies": {
"autoprefixer": "^6.5.4"
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
```
## 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%
Last 2 versions
IE 8 # 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.
## 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 `development` queries and then use defaults.
In `package.json`:
```js
{
"browserslist": {
"production": [
"last 2 version",
"ie 9"
],
"development": [
"last 1 version"
]
}
}
```
In `.browserslistrc` config:
```ini
[production]
last 2 version
ie 9
[development]
last 1 version
```
## 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
## Custom Usage Data
If you have a website, you can query against the usage statistics of your site:
1. Import your Google Analytics data into [Can I Use].
Press `Import…` button in Settings page.
2. Open browser DevTools on [Can I Use] and paste this snippet
into the browser console:
```js
var e=document.createElement('a');e.setAttribute('href', 'data:text/plain;charset=utf-8,'+encodeURIComponent(JSON.stringify(JSON.parse(localStorage['usage-data-by-id'])[localStorage['config-primary_usage']])));e.setAttribute('download','stats.json');document.body.appendChild(e);e.click();document.body.removeChild(e);
```
3. Save the data to a `browserslist-stats.json` file in your project.
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.
[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 `"> 5%, last 1 version"`
or an array `['> 5%', 'last 1 version']`.
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.
For non-JS environment and debug purpose you can use CLI tool:
```sh
browserslist "> 1%, last 2 versions"
```
## 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
```
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
```
## Internal caches
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.
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env node
var browserslist = require('./');
var pkg = require('./package.json');
var args = process.argv.slice(2);
var USAGE = 'Usage:\n' +
' ' + pkg.name + ' "QUERIES"\n' +
' ' + pkg.name + ' --coverage "QUERIES"\n' +
' ' + pkg.name + ' --coverage=US "QUERIES"\n' +
' ' + pkg.name + ' --config="path/to/browserlist/file"\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);
}
}
if ( !queries && !opts.config ) {
error('Define queries or browserslist config path.\n\n' + USAGE);
}
var browsers;
try {
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 result = browserslist.coverage(browsers, country);
var round = Math.round(result * 100) / 100.0;
var end = 'globally';
if (country && country !== 'global') {
end = 'in the ' + country.toUpperCase();
}
process.stdout.write(
'These browsers account for ' + round + '% of all users ' +
end + '\n');
}
}
+706
View File
@@ -0,0 +1,706 @@
var path = require('path');
var e2c = require('electron-to-chromium/versions');
var fs = require('fs');
var caniuse = require('caniuse-lite').agents;
var region = require('caniuse-lite').region;
function normalize(versions) {
return versions.filter(function (version) {
return typeof version === 'string';
});
}
var FLOAT_RANGE = /^\d+(\.\d+)?(-\d+(\.\d+)?)*$/;
var IS_SECTION = /^\s*\[(.+)\]\s*$/;
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;
}
function BrowserslistError(message) {
this.name = 'BrowserslistError';
this.message = message || '';
this.browserslist = true;
if ( Error.captureStackTrace ) {
Error.captureStackTrace(this, BrowserslistError);
}
}
BrowserslistError.prototype = Error.prototype;
// Helpers
function error(name) {
throw new BrowserslistError(name);
}
function fillUsage(result, name, data) {
for ( var i in data ) {
result[name + ' ' + i] = data[i];
}
}
var cacheEnabled = !(
process && process.env && process.env.BROWSERSLIST_DISABLE_CACHE
);
var filenessCache = {};
var configCache = {};
function isFile(file) {
if ( !fs.existsSync ) {
return false;
}
if ( file in filenessCache ) {
return filenessCache[file];
}
var result = fs.existsSync(file) && fs.statSync(file).isFile();
if ( cacheEnabled ) {
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 getStat(opts) {
if ( opts.stats ) {
return opts.stats;
} else if ( process.env.BROWSERSLIST_STATS ) {
return process.env.BROWSERSLIST_STATS;
} else if ( opts.path ) {
return eachParent(opts.path, function (dir) {
var file = path.join(dir, 'browserslist-stats.json');
if ( isFile(file) ) {
return file;
}
});
}
}
function parsePackage(file) {
var config = JSON.parse(fs.readFileSync(file)).browserslist;
if ( typeof config === 'object' && config.length ) {
config = { defaults: config };
}
return config;
}
function pickEnv(config, opts) {
if ( typeof config !== 'object' ) return config;
var env;
if ( typeof opts.env === 'string' ) {
env = opts.env;
} else if ( typeof process.env.BROWSERSLIST_ENV === 'string' ) {
env = process.env.BROWSERSLIST_ENV;
} else if ( typeof process.env.NODE_ENV === 'string' ) {
env = process.env.NODE_ENV;
} else {
env = 'development';
}
return config[env] || config.defaults;
}
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 if ( sign === '<=' ) {
return function (v) {
return parseFloat(v) <= version;
};
}
}
function compareStrings(a, b) {
if ( a < b ) return -1;
if ( a > b ) return +1;
return 0;
}
/**
* Return array of browsers by selection queries.
*
* @param {string[]} queries 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="development"] 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.
* @return {string[]} Array with browser names in Can I Use.
*
* @example
* browserslist('IE >= 10, IE 8') //=> ['ie 11', 'ie 10', 'ie 8']
*/
var browserslist = function (queries, opts) {
if ( typeof opts === 'undefined' ) opts = { };
if ( !opts.hasOwnProperty('path') ) {
opts.path = path.resolve('.');
}
if ( typeof queries === 'undefined' || queries === null ) {
if ( process.env.BROWSERSLIST ) {
queries = 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' ) {
queries = pickEnv(parsePackage(file), opts);
} else {
queries = pickEnv(browserslist.readConfig(file), opts);
}
} else if ( opts.path ) {
queries = pickEnv(browserslist.findConfig(opts.path), opts);
}
}
if ( typeof queries === 'undefined' || queries === null ) {
queries = browserslist.defaults;
}
if ( typeof queries === 'string' ) {
queries = queries.split(/,\s*/);
}
var context = { };
var stats = getStat(opts);
if ( stats ) {
if ( typeof stats === 'string' ) {
try {
stats = JSON.parse(fs.readFileSync(stats));
} catch (e) {
error('Can\'t read ' + stats);
}
}
if ( 'dataByBrowser' in stats ) {
stats = stats.dataByBrowser;
}
context.customUsage = { };
for ( var browser in stats ) {
fillUsage(context.customUsage, browser, stats[browser]);
}
}
var result = [];
queries.forEach(function (selection, index) {
if ( selection.trim() === '' ) return;
var exclude = selection.indexOf('not ') === 0;
if ( exclude ) {
if ( index === 0 ) {
error('Write any browsers query (for instance, `defaults`) ' +
'before `' + selection + '`');
}
selection = selection.slice(4);
}
for ( var i in browserslist.queries ) {
var type = browserslist.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 ( exclude ) {
array = array.concat(array.map(function (j) {
return j.replace(/\s\d+/, ' 0');
}));
result = result.filter(function (j) {
return array.indexOf(j) === -1;
});
} else {
result = result.concat(array);
}
return;
}
}
error('Unknown browser query `' + selection + '`');
});
result = result.map(function (i) {
var parts = i.split(' ');
var name = parts[0];
var version = parts[1];
if ( version === '0' ) {
return name + ' ' + browserslist.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);
};
var normalizeVersion = function (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];
}
};
var loadCountryStatistics = function (country) {
if ( !browserslist.usage[country] ) {
var usage = { };
var data = region(
require('caniuse-lite/data/regions/' + country + '.js'));
for ( var i in data ) {
fillUsage(usage, i, data[i]);
}
browserslist.usage[country] = usage;
}
};
// Will be filled by Can I Use data below
browserslist.data = { };
browserslist.usage = {
global: { },
custom: null
};
// Default browsers query
browserslist.defaults = [
'> 1%',
'last 2 versions',
'Firefox ESR'
];
// 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 = { };
// Get browser data by alias or case insensitive name
browserslist.byName = function (name) {
name = name.toLowerCase();
name = browserslist.aliases[name] || name;
return browserslist.data[name];
};
// Get browser data by alias or case insensitive name and throw error
// on unknown browser
browserslist.checkName = function (name) {
var data = browserslist.byName(name);
if ( !data ) error('Unknown browser ' + name);
return data;
};
// Read and parse config
browserslist.readConfig = function (file) {
if ( !isFile(file) ) {
error('Can\'t read ' + file + ' config');
}
return browserslist.parseConfig(fs.readFileSync(file));
};
// Find config, read file and parse it
browserslist.findConfig = function (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) {
console.warn(
'[Browserslist] Could not parse ' + pkg + '. ' +
'Ignoring it.');
}
}
if ( isFile(config) && pkgBrowserslist ) {
error(
dir + ' contains both browserslist ' +
'and package.json with browsers');
} else if ( isFile(rc) && pkgBrowserslist ) {
error(
dir + ' contains both .browserslistrc ' +
'and package.json with browsers');
} else if ( isFile(config) && isFile(rc) ) {
error(dir + ' contains both .browserslistrc and browserslist');
} else if ( isFile(config) ) {
return browserslist.readConfig(config);
} else if ( isFile(rc) ) {
return browserslist.readConfig(rc);
} else if ( pkgBrowserslist ) {
return pkgBrowserslist;
}
});
if ( cacheEnabled ) {
configCache[cacheKey] = resolved;
}
return resolved;
};
/**
* Return browsers market coverage.
*
* @param {string[]} browsers Browsers names in Can I Use.
* @param {string} [country="global"] Which country statistics should be used.
*
* @return {number} Total market coverage for all selected browsers.
*
* @example
* browserslist.coverage(browserslist('> 1% in US'), 'US') //=> 83.1
*/
browserslist.coverage = function (browsers, country) {
if ( country && country !== 'global' ) {
country = country.toUpperCase();
loadCountryStatistics(country);
} else {
country = 'global';
}
return browsers.reduce(function (all, i) {
var usage = browserslist.usage[country][i];
if ( usage === undefined ) {
usage = browserslist.usage[country][i.replace(/ [\d.]+$/, ' 0')];
}
return all + (usage || 0);
}, 0);
};
// Return array of queries from config content
browserslist.parseConfig = function (string) {
var result = { defaults: [] };
var section = '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) ) {
section = line.match(IS_SECTION)[1].trim();
result[section] = result[section] || [];
} else {
result[section].push(line);
}
});
return result;
};
// Clear internal caches
browserslist.clearCaches = function () {
filenessCache = {};
configCache = {};
};
browserslist.queries = {
lastVersions: {
regexp: /^last\s+(\d+)\s+versions?$/i,
select: function (context, versions) {
var selected = [];
Object.keys(caniuse).forEach(function (name) {
var data = browserslist.byName(name);
if ( !data ) return;
var array = data.released.slice(-versions);
array = array.map(function (v) {
return data.name + ' ' + v;
});
selected = selected.concat(array);
});
return selected;
}
},
lastByBrowser: {
regexp: /^last\s+(\d+)\s+(\w+)\s+versions?$/i,
select: function (context, versions, name) {
var data = browserslist.checkName(name);
return data.released.slice(-versions).map(function (v) {
return data.name + ' ' + v;
});
}
},
globalStatistics: {
regexp: /^(>=?)\s*(\d*\.?\d+)%$/,
select: function (context, sign, popularity) {
popularity = parseFloat(popularity);
var result = [];
for ( var version in browserslist.usage.global ) {
if ( sign === '>' ) {
if ( browserslist.usage.global[version] > popularity ) {
result.push(version);
}
} else if ( browserslist.usage.global[version] >= popularity ) {
result.push(version);
}
}
return result;
}
},
customStatistics: {
regexp: /^(>=?)\s*(\d*\.?\d+)%\s+in\s+my\s+stats$/,
select: function (context, sign, popularity) {
popularity = parseFloat(popularity);
var result = [];
if ( !context.customUsage ) {
error('Custom usage statistics was not provided');
}
for ( var version in context.customUsage ) {
if ( sign === '>' ) {
if ( context.customUsage[version] > popularity ) {
result.push(version);
}
} else if ( context.customUsage[version] >= popularity ) {
result.push(version);
}
}
return result;
}
},
countryStatistics: {
regexp: /^(>=?)\s*(\d*\.?\d+)%\s+in\s+(\w\w)$/,
select: function (context, sign, popularity, country) {
popularity = parseFloat(popularity);
country = country.toUpperCase();
var result = [];
loadCountryStatistics(country);
var usage = browserslist.usage[country];
for ( var version in usage ) {
if ( sign === '>' ) {
if ( usage[version] > popularity ) {
result.push(version);
}
} else if ( usage[version] >= popularity ) {
result.push(version);
}
}
return result;
}
},
electronRange: {
regexp: /^electron\s+([\d\.]+)\s*-\s*([\d\.]+)$/i,
select: function (context, from, to) {
if ( !e2c[from] ) error('Unknown version ' + from + ' of electron');
if ( !e2c[to] ) error('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];
});
}
},
range: {
regexp: /^(\w+)\s+([\d\.]+)\s*-\s*([\d\.]+)$/i,
select: function (context, name, from, to) {
var data = browserslist.checkName(name);
from = parseFloat(normalizeVersion(data, from) || from);
to = parseFloat(normalizeVersion(data, to) || to);
var filter = function (v) {
var parsed = parseFloat(v);
return parsed >= from && parsed <= to;
};
return data.released.filter(filter).map(function (v) {
return data.name + ' ' + v;
});
}
},
electronVersions: {
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];
});
}
},
versions: {
regexp: /^(\w+)\s*(>=?|<=?)\s*([\d\.]+)$/,
select: function (context, name, sign, version) {
var data = browserslist.checkName(name);
var alias = normalizeVersion(data, version);
if ( alias ) {
version = alias;
}
return data.released
.filter(generateFilter(sign, version))
.map(function (v) {
return data.name + ' ' + v;
});
}
},
esr: {
regexp: /^(firefox|ff|fx)\s+esr$/i,
select: function () {
return ['firefox 52', 'firefox 45'];
}
},
opMini: {
regexp: /(operamini|op_mini)\s+all/i,
select: function () {
return ['op_mini all'];
}
},
electron: {
regexp: /^electron\s+([\d\.]+)$/i,
select: function (context, version) {
var chrome = e2c[version];
if ( !chrome ) error('Unknown version ' + version + ' of electron');
return ['chrome ' + chrome];
}
},
direct: {
regexp: /^(\w+)\s+(tp|[\d\.]+)$/i,
select: function (context, name, version) {
if ( /tp/i.test(version) ) version = 'TP';
var data = browserslist.checkName(name);
var alias = normalizeVersion(data, version);
if ( alias ) {
version = alias;
} else {
if ( version.indexOf('.') === -1 ) {
alias = version + '.0';
} else if ( /\.0$/.test(version) ) {
alias = version.replace(/\.0$/, '');
}
alias = normalizeVersion(data, alias);
if ( alias ) {
version = alias;
} else {
error('Unknown version ' + version + ' of ' + name);
}
}
return [data.name + ' ' + version];
}
},
defaults: {
regexp: /^defaults$/i,
select: function () {
return browserslist(browserslist.defaults);
}
}
};
// Get and convert Can I Use data
(function () {
for ( var name in caniuse ) {
var browser = caniuse[name];
browserslist.data[name] = {
name: name,
versions: normalize(caniuse[name].versions),
released: normalize(caniuse[name].versions.slice(0, -3))
};
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;
+131
View File
@@ -0,0 +1,131 @@
{
"_args": [
[
{
"raw": "browserslist@^2.1.2",
"scope": null,
"escapedName": "browserslist",
"name": "browserslist",
"rawSpec": "^2.1.2",
"spec": ">=2.1.2 <3.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\babel-preset-env"
]
],
"_from": "browserslist@>=2.1.2 <3.0.0",
"_id": "browserslist@2.1.4",
"_inCache": true,
"_location": "/babel-preset-env/browserslist",
"_nodeVersion": "7.10.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/browserslist-2.1.4.tgz_1495388099839_0.8967401522677392"
},
"_npmUser": {
"name": "ai",
"email": "andrey@sitnik.ru"
},
"_npmVersion": "4.2.0",
"_phantomChildren": {},
"_requested": {
"raw": "browserslist@^2.1.2",
"scope": null,
"escapedName": "browserslist",
"name": "browserslist",
"rawSpec": "^2.1.2",
"spec": ">=2.1.2 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-preset-env"
],
"_resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.1.4.tgz",
"_shasum": "cc526af4a1312b7d2e05653e56d0c8ab70c0e053",
"_shrinkwrap": null,
"_spec": "browserslist@^2.1.2",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\babel-preset-env",
"author": {
"name": "Andrey Sitnik",
"email": "andrey@sitnik.ru"
},
"bin": {
"browserslist": "./cli.js"
},
"browser": {
"fs": false
},
"bugs": {
"url": "https://github.com/ai/browserslist/issues"
},
"dependencies": {
"caniuse-lite": "^1.0.30000670",
"electron-to-chromium": "^1.3.11"
},
"description": "Share browsers list between different front-end tools, like Autoprefixer, Stylelint and babel-env-preset",
"devDependencies": {
"cross-spawn": "^5.1.0",
"eslint": "^3.19.0",
"eslint-config-postcss": "^2.0.2",
"jest": "^20.0.3",
"lint-staged": "^3.4.2",
"pre-commit": "^1.1.3",
"yaspeller-ci": "^0.4.0"
},
"directories": {},
"dist": {
"shasum": "cc526af4a1312b7d2e05653e56d0c8ab70c0e053",
"tarball": "https://registry.npmjs.org/browserslist/-/browserslist-2.1.4.tgz"
},
"eslintConfig": {
"extends": "eslint-config-postcss/es5",
"env": {
"jest": true
},
"rules": {
"consistent-return": "off",
"no-process-exit": "off",
"valid-jsdoc": "error"
}
},
"gitHead": "0d5fb417168d126dafbc54a08f08bff8397d6a08",
"homepage": "https://github.com/ai/browserslist#readme",
"jest": {
"coverageThreshold": {
"global": {
"statements": 100
}
}
},
"keywords": [
"caniuse",
"browsers"
],
"license": "MIT",
"lint-staged": {
"*.md": "yaspeller-ci",
"*.js": "eslint"
},
"maintainers": [
{
"name": "ai",
"email": "andrey@sitnik.ru"
}
],
"name": "browserslist",
"optionalDependencies": {},
"pre-commit": [
"lint-staged"
],
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/ai/browserslist.git"
},
"scripts": {
"lint-staged": "lint-staged",
"spellcheck": "yaspeller-ci README.md CHANGELOG.md",
"test": "jest --coverage && eslint *.js test/*.js && yarn run spellcheck"
},
"version": "2.1.4"
}
+190
View File
@@ -0,0 +1,190 @@
{
"_args": [
[
{
"raw": "babel-preset-env@^1.3.0",
"scope": null,
"escapedName": "babel-preset-env",
"name": "babel-preset-env",
"rawSpec": "^1.3.0",
"spec": ">=1.3.0 <2.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\laravel-mix"
]
],
"_from": "babel-preset-env@>=1.3.0 <2.0.0",
"_id": "babel-preset-env@1.5.2",
"_inCache": true,
"_location": "/babel-preset-env",
"_nodeVersion": "6.9.4",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/babel-preset-env-1.5.2.tgz_1496846306790_0.37454386381432414"
},
"_npmUser": {
"name": "existentialism",
"email": "bng412@gmail.com"
},
"_npmVersion": "3.10.10",
"_phantomChildren": {
"caniuse-lite": "1.0.30000683",
"electron-to-chromium": "1.3.14"
},
"_requested": {
"raw": "babel-preset-env@^1.3.0",
"scope": null,
"escapedName": "babel-preset-env",
"name": "babel-preset-env",
"rawSpec": "^1.3.0",
"spec": ">=1.3.0 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/laravel-mix"
],
"_resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.5.2.tgz",
"_shasum": "cd4ae90a6e94b709f97374b33e5f8b983556adef",
"_shrinkwrap": null,
"_spec": "babel-preset-env@^1.3.0",
"_where": "c:\\xampp\\htdocs\\laravel\\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"
},
"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": "^2.1.2",
"invariant": "^2.2.2",
"semver": "^5.3.0"
},
"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#1f0bb0913736fe8c4c11b139766c73b9cbedb9f2",
"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"
},
"directories": {},
"dist": {
"shasum": "cd4ae90a6e94b709f97374b33e5f8b983556adef",
"tarball": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.5.2.tgz"
},
"gitHead": "f4ce53c4cfb9ea0bc222a8ec138d8a76f8bc5fc2",
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "sebmck",
"email": "sebmck@gmail.com"
},
{
"name": "danez",
"email": "daniel@tschinder.de"
},
{
"name": "hzoo",
"email": "hi@henryzoo.com"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth@gmail.com"
},
{
"name": "existentialism",
"email": "bng412@gmail.com"
}
],
"name": "babel-preset-env",
"nyc": {
"all": true,
"include": [
"src/*.js"
],
"instrument": false,
"sourceMap": false
},
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"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.5.2"
}