When I list the presets, does the order matter?
In other words, are the following .babelrc
files equivalent?
.babelrc
#1
{ "presets": ["es2015", "stage-2", "react"] }
.babelrc
#2
{ "presets": ["react", "stage-2", "es2015"] }
From babeljs.io/docs/plugins: (as of 9/30/2016)
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.
"plugins": [ "transform-decorators-legacy", // will run first "transform-class-properties" // will run second ]
Yes this is confusing, see babel/notes #2.
I believe the reason why (for backwards compatability) is that most users had listed “es2015” first and “stage-0” second. And stage-0 would run before es2015.
"presets": [ "es2015", // will run third "react", // will run second "stage-2" // will run first ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With