As of version 6, Babel supports presets, sets of features that can be enabled together. This blog post looks at three new useful Babel presets (and, as a bonus, two presets especially for Node.js).
These two presets are useful complements to
babel-preset-es2015 (for ES6):
babel-preset-es2016gives you one of the two features of ES2016: the exponentiation operator. The other feature,
Array.prototype.includes(), is supported via the standard library polyfill.
Note that if you want all of ES2017 (as much as it is supported by Babel) then you need three presets:
es2017. Alternatively, there is also a meta-preset:
babel-preset-latestwill always contain all the “yearly” presets. At the moment, those are:
babel-preset-es2015. It checks the Node.js version and only enables plugins whose functionality is missing (not much in recent versions).
babel-preset-latest. It determines what plugins are needed via feature detection. As the repository’s readme states: that only makes sense for Node.js, but not for browsers.