My question is : What's the difference between babel-preset-stage-0
,babel-preset-stage-1
,babel-preset-stage-2
and babel-preset-stage-3
, and what's the best choice when we develop with ES6
?
Stage 1 - Proposal: this is worth working on. Stage 2 - Draft: initial spec. Stage 3 - Candidate: complete spec and initial browser implementations. Stage 4 - Finished: will be added to the next yearly release.
@babel/preset-env is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s). This both makes your life easier and JavaScript bundles smaller!
A preset is a set of plugins used to support particular language features. The two presets Babel uses by default: es2015: Adds support for ES2015 (or ES6) JavaScript. react: Adds support for JSX.
The . babelrc file is your local configuration for your code in your project. Generally you would put it in the root of your application repo. It will affect all files that Babel processes that are in the same directory or in sibling directories of the . babelrc .
Babel's stage presets equate to the TC39 Process and the different states of each proposal for a potential language change. They include implementations and polyfills for all of the proposed changes in that stage.
Anything currently in Stage-0
is Strawman, not ES6. It is future Javascript and absolutely not certain that it will ever make it into any official ECMAScript specification.
Please do not just set to stage-0
so it will work without understanding the consequences this will have.
The Babel Preset which contains only ES6 features is preset-es2015
As mostly elaborated by other answers. Stage 4 is most Stable and Stage 0, the most dangerous. Here is a bit of a breakdown at a high level for the 5 stages from the previous answers and the documentation. I'm adding this because when I came to this I was expecting a more high-level break down of what each stage is:
Ready for inclusion in ECMAScript Standard, has passed testing and will be part of the next revision
Includes a full spec text and includes plugins that have mostly been tested and provided with feedback. Solution is complete and all further changes are based on implementation experience.
Further support for plugins completed as much as possible. Requirements for these are met mostly with only incremental changes on the way. Semantics and api is expected to be complete. It will most likely become part of the spec.
Each level is inclusive whereas 4 includes 3 includes 2 and so on... I hope that this summation helps someone in the future.
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