租租车javascript babel预设转换器
目前包含的plugins/presets:
- @babel/preset-env
- @babel/preset-react
- @babel/preset-typescript
- @babel/plugin-proposal-class-properties
- @babel/plugin-proposal-decorators
- @babel/plugin-proposal-nullish-coalescing-operator
- @babel/plugin-proposal-numeric-separator
- @babel/plugin-proposal-optional-chaining
- @babel/plugin-proposal-private-methods
- @babel/plugin-proposal-private-property-in-object
- @babel/plugin-transform-runtime
- babel-plugin-transform-react-remove-prop-types
$ npm install --save-dev babel-preset-zuzuche
.babelrc
{
"presets": ["zuzuche"]
}
$ babel script.js --presets zuzuche
require("babel-core").transform("code", {
presets: ["zuzuche"]
});
目前使用 babel-preset-env
来配置支持的运行环境
targets
参数支持多种传递格式,详情查看 babel-preset-env#targets
如需支持更多自定义的运行环境,需了解 browserslist
,详情查看 browserlist.
默认运行环境配置:
{
"presets": [["zuzuche", {
"targets": {
"chrome": 45,
"firefox": 52,
"safari": 8,
"ios": 9,
"android": 4,
"ie": 9,
"edge": 12
}
}]]
}
只支持国内主流PC端配置:
{
"presets": [["zuzuche", {
"targets": ["chrome >= 45", "firefox >= 52", "safari >= 8", "ie >= 9", "edge >= 12"]
}]]
}
只支持国内主流移动端配置:
{
"presets": [["zuzuche", {
"targets": ["iOS >= 12", "Android >= 6", "last 2 ChromeAndroid versions"]
}]]
}
为了提供便利性,内置了 presets/plugins
的默认配置,你可以通过 .babelrc
文件进行修改
{
"presets": [
["zuzuche", {
"env": {},
"react": {},
"transform-runtime": {},
"class-properties": {},
"private-methods": {},
"private-property-in-object": {}
}]
]
}