Babel
ES6 to ES5 compiler (parsing, transforming, and generation). For an simple tutorial on compilers, check out the-super-tiny-compiler, which also explains how Babel itself works on a high level. And a Good article on Babel.
5 flashcards · Programming Languages · by lakesare
What does Babel do out of the box?
Nothing. const babel = code => code. You need to add some plugins for Babel to do anything.
What are Babel presets?
Preset is simply an array of plugins. Presets are sharable .babelrc configs or simply an array of babel plugins.
What are ECMAScript proposal stages?
Level of readiness of proposal. stage-0 - basically anything qualifies, will probably never be included, stage-4 - will be included in the soonest next version (as determined by The Ecma TC39 committee, https://tc39.github.io/process-document/)
Each preset called babel-preset-stage-0 babel-preset-stage-1 babel-preset-stage-2 babel-preset-stage-3 is a set of plugins corresponding to some ECMAScript proposal stage.
That is, if we are using babel-preset-stage-0 preset, we can be writing code with features that will be valid in some future version of ES if they ever move to stage-4.
What will happen If we include babel-preset-stage-2 preset?
babel-preset-stage-3 will get automatically included! If we include babel-preset-stage-1, it will include babel-preset-stage-2 and babel-preset-stage-3.