My question is : What\'s the difference between babel-preset-stage-0
,babel-preset-stage-1
,babel-preset-stage-2
and babel-preset-
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.
This is the best starting point to understand. What are babel presets
An excerpt from the link:
Stage 0 - Strawman: just an idea, possible Babel plugin.
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
Overall Picture:
preset
in babel's terms. And each preset contains plugins from various levels of risk.preset-0
It means it has plugins for features which are very experimental and hence at high risk of making it out to final spec. Its like an idea that came to a developer that Javascript should have a particular feature, and he did some work to get it to TC-39 proposal process. preset-1
It contains the plugins for the feature ideas accepted by the TC-39, and they find it worth working on.preset-2
Plugins for features where an initial draft is ready for the feature.
And it goes on..So it could happen that a feature in Stage 0 reached Stage 2 in some time and end up being in next release of Javascript some more time later.
Hence with each version of these Babel Presets, you could find different set of plugins in it. It could also happen that a feature in stage 0 went through some changes and it made breaking changes into how it functions. And it reached, lets say stage-2 with a totally different API. So developers have to make sure that when they are updating these plugins they make necessary changes to their code.
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
The stages represent the stages as defined by the TC39 process that works features from crazy but useful ideas into accepted standards, such as ES6. The process takes some time, as every corner case must be discussed, thought about, tested, polyfilled, discussed some more, etc. That is, it is a standards body. The goal is that saying "ES6" will have a full and complete meaning, much as saying "ES5" does.
In practice, your project requirements may range from staying to the tried and true to playing around with oh-so-convenient, if nebulous, language features. You probably want to start with these links:
The TC39 Process Overview: This includes a nifty chart as to what the stages mean and how features progress from stage to stage. Below that is an overview of TC39.
The Active Proposals: A quick overview of what stage certain proposals are in. It also includes links to the Finished, Inactive, and Stage 0 proposals. Today, April 2017, Public Class Fields is in stage 2, meaning it is precisely described and reviewers have been assigned, but is not fully reviewed.
The Babel Preset Package for Stage 3: The plug-in page, with links to Git and NPM, for all Stage 3 proposals. Basically, this plug-in pulls in the collection of packages that, in theory, polyfill the current proposals in TC39 stage 3. In practice, bugs may occur. Also, you can find the similar Similarly, it links to the plug-in pages for Stage 2 and below. Those pages will link to packages that include both Stage 3 proposals and less stable proposals.
Babel Preset 'env': This Babel preset supports completed proposals, selecting the correct packages needed to support these features in a known environment. For example, a local node
executable requires fewer plugins than an older browser. It can be thought of the 'stage-4' plugin that supports approved future features.
In summary, you only need to deal with these prerelease features if you use them. If you do need to use them, pick the highest number of stage that has what you need. If you just want an toy installation with crazy features to discuss around the water cooler, go ahead and grab stage 0.
The original question is "What's the difference between babel-preset-stage-0,babel-preset-stage-1,babel-preset-stage-2 and babel-preset-stage-3", it's odd that answers focusing on "difference between TC39 stage-0, stage-1.. terminology" get voted, while the only one relevant(though not accurate) is down voted. To quote from babel site:
A Babel preset is a shareable list of plugins.
The official Babel Stage presets tracked the TC39 Staging process for new syntax proposals in JavaScript.
Each preset (ex. stage-3, stage-2, etc.) included all the plugins for that particular stage and the ones above it. For example, stage-2 included stage-3, and so on.
The core idea is 'the ones above it'. I am not answer the second half as answers above are very good on that part.