- 使用npm的scope包
@balbel/xxx
- 所有阶段预设
state-x
均已弃用,使用plugin代替
{
"plugins": [
// Stage 0
"@babel/plugin-proposal-function-bind",
// Stage 1
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-logical-assignment-operators",
["@babel/plugin-proposal-optional-chaining", { "loose": false }],
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }],
["@babel/plugin-proposal-nullish-coalescing-operator", { "loose": false }],
"@babel/plugin-proposal-do-expressions",
// Stage 2
["@babel/plugin-proposal-decorators", { "legacy": true }], //解析装饰器
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
// Stage 3
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-syntax-import-meta",
["@babel/plugin-proposal-class-properties", { "loose": false }],
"@babel/plugin-proposal-json-strings"
]
}
- @babel/polyfill是@babel/runtime-corejs2的别名
{
"presets": [
["@babel/preset-env", {"useBuiltIns": "usage"}]
],
"plugins": [
["@babel/plugin-transform-runtime",{"corejs": 2}]
]
}
参考
babeljs 6.x
babeljs 7.x
关于babel 的一些包理解7.X版本