forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da53fd7
commit 12b738f
Showing
5 changed files
with
338 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,4 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
lib | ||
.DS_Store | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
src | ||
test | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# babel-preset-env | ||
|
||
> Babel preset for all envs. | ||
## Install | ||
|
||
```sh | ||
$ npm install --save-dev babel-preset-env | ||
``` | ||
|
||
## Usage | ||
|
||
### Via `.babelrc` (Recommended) | ||
|
||
**.babelrc** | ||
|
||
```json | ||
{ | ||
"presets": ["env"] | ||
} | ||
``` | ||
|
||
### Via CLI | ||
|
||
```sh | ||
$ babel script.js --presets env | ||
``` | ||
|
||
### Via Node API | ||
|
||
```javascript | ||
require("babel-core").transform("code", { | ||
presets: ["env"] | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
* `loose` - Enable "loose" transformations for any plugins in this preset that allow them (Disabled by default). | ||
|
||
``` | ||
{ | ||
presets: [ | ||
["env", { | ||
chrome: 49 | ||
}] | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"name": "babel-preset-env", | ||
"version": "1.0.0", | ||
"description": "A Babel preset for each environment.", | ||
"author": "Henry Zhu <hi@henryzoo.com>", | ||
"homepage": "https://babeljs.io/", | ||
"license": "MIT", | ||
"repository": "https://github.com/babel/babel-preset-env", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel src -d lib", | ||
"dev": "babel -w src -d lib", | ||
"lint": "eslint src test", | ||
"fix": "eslint src test --fix", | ||
"ci": "npm run lint && npm run test", | ||
"prepublish": "npm run build" | ||
}, | ||
"dependencies": { | ||
"babel-plugin-transform-es2015-modules-amd": "^6.8.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.6.0", | ||
"babel-plugin-transform-es2015-modules-systemjs": "^6.12.0", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.12.0", | ||
"babel-plugin-transform-es3-member-expression-literals": "^6.3.13", | ||
"babel-plugin-transform-es3-property-literals": "^6.3.13", | ||
"babel-plugin-transform-proto-to-assign": "^6.9.0", | ||
"babel-plugin-transform-es5-property-mutators": "^6.3.13", | ||
"babel-plugin-check-es2015-constants": "^6.3.13", | ||
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13", | ||
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13", | ||
"babel-plugin-transform-es2015-block-scoping": "^6.6.0", | ||
"babel-plugin-transform-es2015-classes": "^6.6.0", | ||
"babel-plugin-transform-es2015-computed-properties": "^6.3.13", | ||
"babel-plugin-transform-es2015-destructuring": "^6.6.0", | ||
"babel-plugin-transform-es2015-duplicate-keys": "^6.6.0", | ||
"babel-plugin-transform-es2015-for-of": "^6.6.0", | ||
"babel-plugin-transform-es2015-function-name": "^6.3.13", | ||
"babel-plugin-transform-es2015-literals": "^6.3.13", | ||
"babel-plugin-transform-es2015-object-super": "^6.3.13", | ||
"babel-plugin-transform-es2015-parameters": "^6.6.0", | ||
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13", | ||
"babel-plugin-transform-es2015-spread": "^6.3.13", | ||
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13", | ||
"babel-plugin-transform-es2015-template-literals": "^6.6.0", | ||
"babel-plugin-transform-es2015-typeof-symbol": "^6.6.0", | ||
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13", | ||
"babel-plugin-transform-regenerator": "^6.6.0", | ||
"babel-plugin-transform-exponentiation-operator": "^6.8.0", | ||
"babel-plugin-syntax-trailing-function-commas": "^6.13.0", | ||
"babel-plugin-transform-async-to-generator": "^6.8.0", | ||
"babel-plugin-transform-class-properties": "^6.11.5", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"babel-plugin-transform-do-expressions": "^6.8.0", | ||
"babel-plugin-transform-export-extensions": "^6.8.0", | ||
"babel-plugin-transform-function-bind": "^6.8.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.8.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.11.4", | ||
"babel-eslint": "^6.1.2", | ||
"babel-plugin-transform-flow-strip-types": "^6.8.0", | ||
"eslint": "^3.3.1", | ||
"eslint-config-babel": "^1.0.1", | ||
"eslint-plugin-babel": "^3.3.0", | ||
"eslint-plugin-flow-vars": "^0.5.0" | ||
}, | ||
"babel": { | ||
"plugins": [ | ||
"transform-class-properties", | ||
"transform-flow-strip-types" | ||
] | ||
}, | ||
"eslint": { | ||
"extends": "babel", | ||
"parserOptions": { | ||
"ecmaVersion": 7, | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"max-len": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
// use if ie | ||
// "es3-member-expression-literals", | ||
// "es3-property-literals", | ||
// "proto-to-assign", | ||
// "es5-property-mutators", | ||
|
||
export const pluginsList = { | ||
// es2015 | ||
"transform-es2015-arrow-functions": { | ||
edge: 13, | ||
firefox: 45, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
"transform-es2015-block-scoped-functions": { | ||
edge: 11, | ||
firefox: 46, | ||
chrome: 41, | ||
opera: 28, | ||
}, | ||
"transform-es2015-block-scoping": { | ||
edge: 11, | ||
firefox: 36, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
"transform-es2015-classes": { | ||
edge: 13, | ||
firefox: 45, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
"transform-es2015-computed-properties": { | ||
edge: 12, | ||
firefox: 34, | ||
chrome: 44, | ||
opera: 31 | ||
}, | ||
"check-es2015-constants": { | ||
edge: 11, | ||
firefox: 36, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
"transform-es2015-destructuring": { | ||
edge: 14, | ||
firefox: Infinity, | ||
chrome: 52, | ||
opera: 39, | ||
}, | ||
"transform-es2015-for-of": { | ||
edge: Infinity, | ||
firefox: Infinity, | ||
chrome: 51, | ||
opera: 38, | ||
}, | ||
"transform-es2015-function-name": { | ||
edge: Infinity, | ||
firefox: Infinity, | ||
chrome: 52, | ||
opera: 39, | ||
}, | ||
"transform-es2015-literals": { | ||
edge: 12, | ||
firefox: 36, | ||
chrome: 41, | ||
opera: 28 | ||
}, | ||
"transform-es2015-object-super": { | ||
edge: 13, | ||
firefox: 45, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
"transform-es2015-parameters": { | ||
edge: 14, | ||
firefox: Infinity, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
"transform-es2015-shorthand-properties": { | ||
edge: 12, | ||
firefox: 33, | ||
chrome: 43, | ||
opera: 30 | ||
}, | ||
"transform-es2015-spread": { | ||
edge: 13, | ||
firefox: 36, | ||
chrome: 46, | ||
opera: 33, | ||
}, | ||
"transform-es2015-sticky-regex": { | ||
edge: 13, | ||
firefox: 31, | ||
chrome: 49, | ||
opera: 36 | ||
}, | ||
"transform-es2015-template-literals": { | ||
edge: 13, | ||
firefox: 34, | ||
chrome: 41, | ||
opera: 28, | ||
}, | ||
"transform-es2015-typeof-symbol": { | ||
edge: 12, | ||
firefox: 36, | ||
chrome: 38, | ||
opera: 25, | ||
}, | ||
"transform-es2015-unicode-regex": { | ||
edge: 12, | ||
firefox: 46, | ||
chrome: 51, | ||
opera: 38, | ||
}, | ||
"transform-regenerator": { | ||
edge: 13, | ||
firefox: 45, | ||
chrome: 49, | ||
opera: 36, | ||
}, | ||
|
||
// es2016 | ||
"transform-exponentiation-operator": { | ||
edge: 14, | ||
chrome: 52, | ||
}, | ||
|
||
// es2017 | ||
"transform-async-to-generator": { | ||
edge: 14, | ||
}, | ||
"syntax-trailing-function-commas": { | ||
edge: 14, | ||
} | ||
}; | ||
|
||
export const plugins = [ | ||
"es3-member-expression-literals", | ||
"es3-property-literals", | ||
"proto-to-assign", | ||
|
||
"es5-property-mutators", | ||
|
||
// es2015 | ||
"transform-es2015-arrow-functions", | ||
"transform-es2015-block-scoped-functions", | ||
"transform-es2015-block-scoping", | ||
"transform-es2015-classes", | ||
"transform-es2015-computed-properties", | ||
"check-es2015-constants", | ||
"transform-es2015-destructuring", | ||
"transform-es2015-for-of", | ||
"transform-es2015-function-name", | ||
"transform-es2015-literals", | ||
"transform-es2015-object-super", | ||
"transform-es2015-parameters", | ||
"transform-es2015-shorthand-properties", | ||
"transform-es2015-spread", | ||
"transform-es2015-sticky-regex", | ||
"transform-es2015-template-literals", | ||
"transform-es2015-typeof-symbol", | ||
"transform-es2015-unicode-regex", | ||
"transform-regenerator", | ||
|
||
// es2016 | ||
"transform-exponentiation-operator", | ||
|
||
// es2017 | ||
"transform-async-to-generator", | ||
"syntax-trailing-function-commas" | ||
]; | ||
|
||
// modules? | ||
export const modules = [ | ||
"transform-es2015-modules-amd", | ||
"transform-es2015-modules-commonjs", | ||
"transform-es2015-modules-systemjs", | ||
"transform-es2015-modules-umd" | ||
]; | ||
|
||
export const stagePlugins = [ | ||
// "transform-class-constructor-call", proposal is removed | ||
"transform-class-properties", | ||
"transform-transform-decorators-legacy", // legacy plugin | ||
"transform-do-expressions", | ||
"transform-export-extensions", | ||
"transform-function-bind", | ||
"transform-object-rest-spread", | ||
]; | ||
|
||
export default function(opts) { | ||
let stage = 4; | ||
if (opts !== undefined){ | ||
if (opts.stage !== undefined) stage = opts.stage; | ||
} | ||
|
||
if (typeof stage !== "boolean") throw new Error("Preset es2015 'loose' option must be a boolean."); | ||
|
||
} |