[英]Does the order of Babel 6 presets matter?
When I list the presets, does the order matter? 当我列出预设时,订单是否重要?
In other words, are the following .babelrc
files equivalent? 换句话说,以下
.babelrc
文件是等效的吗?
.babelrc
#1 .babelrc
#1
{
"presets": ["es2015", "stage-2", "react"]
}
.babelrc
#2 .babelrc
#2
{
"presets": ["react", "stage-2", "es2015"]
}
From babeljs.io/docs/plugins: (as of 9/30/2016) 来自babeljs.io/docs/plugins :(截至2016年9月30日 )
Ordering matters for each visitor in the plugin. 订购插件中每个访问者的事项。 This means if two transforms both visit “Program”, the transforms will run in either plugin or preset order.
这意味着如果两个变换都访问“Program”,则变换将以插件或预设顺序运行。
"plugins": [
"transform-decorators-legacy", // will run first
"transform-class-properties" // will run second
]
Yes this is confusing, see babel/notes #2 . 是的这令人困惑,请参阅babel / notes#2 。
I believe the reason why (for backwards compatability) is that most users had listed “es2015” first and “stage-0” second. 我认为(对于向后兼容性)的原因是大多数用户首先列出“es2015”和“0”秒。 And stage-0 would run before es2015.
而阶段0将在2015年之前运行。
"presets": [
"es2015", // will run third
"react", // will run second
"stage-2" // will run first
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.