What is the difference between babel-preset-stage-0, babel-preset-stage-1, etc.?

My question is: what is the difference between babel-preset-stage-0 , babel-preset-stage-1 , babel-preset-stage-2 and babel-preset-stage-3 , and what is the best choice when we are developing with ES6 ?

+114
ecmascript-6 babel
May 16 '16 at 10:18
source share
6 answers

Presets of the bubble scene are equated to the TC39 Process and the different states of each sentence for potential language changes. They include implementations and polyfillings for all proposed changes at this stage.

All that is currently in Stage-0 is Strawman, not ES6. This is the future Javascript and is absolutely not sure that it will ever turn into any official ECMAScript specification.

Please do not just install Stage-0 so that it works without understanding the consequences this may have.

Preset Babel, which contains only ES6 features, preset-es2015

+90
May 16 '16 at 10:56
source share

As basically, other answers are developed. Stage 4 is the most stable, and stage 0 is the most dangerous. Here is a small high-level breakdown for the 5 steps from previous answers and documentation. I add this because when I came to this, I expected a higher level of breakdown of what each step represents:




Stage 4: Finished

Ready for inclusion in the ECMAScript standard, passed the test and will be part of the next edition




Stage 3: Candidate

It includes the full text of the specification and includes plugins, which were mainly tested and provided with feedback. The decision is complete, and all further changes are based on implementation experience.




Stage 2: Draft

Further plugin support is completed as much as possible. The requirements for them are met mainly only with gradual changes along the way. Semantics and APIs are expected to be completed. Most likely, it will become part of the specification.




Stage 1: Proposal . The concept, which was discovered and selected for study at this stage, is expected to be largely filled and demonstrated.




Stage 0: Strawman. This name made me laugh in accordance with TC-39, it does not seem to have any restrictions, but given the context, this is a category for concepts that have not been selected for further study or study.

Each level is inclusive, while 4 includes 3, includes 2, and so on ... I hope this summation helps someone in the future.

+48
Jan 30 '18 at 21:07
source share

The steps represent the steps identified in the TC39 process, which works with crazy but useful ideas, into accepted standards such as ES6. The process takes some time, since each regional issue should be discussed, analyzed, verified, filled out, discussed more, etc. That is, it is an organ of standards. The goal is that the expression “ES6” will have full and complete meaning, as ES5 says.

In practice, your project requirements can range from staying to proven and truthful, to play around with such convenient, albeit vague language features. You probably want to start with these links:

  • TC39 Process Overview : Includes an excellent schedule of what the stages mean and how the functions progress from stage to stage. Below is an overview of the TC39.

  • Active offers : a quick overview of what stage certain offers are at. It also includes links to completed, inactive, and sentences of stage 0. Today, April 2017, Public Class Fields is in stage 2, that is, it is accurately described and reviewers are appointed, but not completely revised.

  • Babel Preset Package for Stage 3 : Plug-in page with links to Git and NPM for all Stage 3 Proposals. Basically, this plug-in draws in a collection of packages that, theoretically, polyfill current offers in step TC39 3. In practice, errors may occur. In addition, you can find a similar one in the same way, it links to the plug-in pages for Stage 2 and below. These pages will link to packages that include both the stages of the 3rd sentence and less stable offers.

  • Babel Preset 'env' : This preset Babel supports completed sentences by selecting the correct packages needed to support these features in the renowned Environment. For example, a local node executable requires fewer plugins than an older browser. You might think of a "stage-4" plugin that supports the approved features of the future.

Thus, you only need to deal with these preliminary functions if you use them. If you need to use them, select the largest number of scenes that you need. If you just want to install a toy with crazy features to discuss around the water cooler, go ahead and take step 0.

+15
Apr 20 '17 at 2:54 on
source share

This is the best starting point for understanding. What are presets?

Excerpt from the link:

Stage 0 - Strawman: Just an Idea, Babel Plugin Possible.
Stage 1 - Suggestion: It’s worth working on.
Stage 2 - Draft: initial special.
Stage 3 - Candidate: full specification and initial implementation of the browser.
Stage 4 - Finished: to be added to the next annual release

The big picture :

  1. Over time, Javascript evolves and more and more functions are added to it.
  2. Browsers also need to do a lot of work so that they can implement these new features for them to understand. This process as a whole is much slower than the development speed of Javascript.
  3. But developers want to use the new features of the language, since it is easier for them to write, understand, maintain code.
  4. Thus, developers write their code using the new Javascript functions, but before this code reaches the browsers, it goes through the assembly process, where, using some magic, all the code with the new functions is translated into code that the browser understands. i.e. new Javascript features, but encoded using browser-friendly language constructs.
  5. Assembly magic can be done with tools, one of which is Babylon.
  6. Babel works so that it requires a set of plugins. Each of these plugins can relate to converting a specific new Javscript function into browser-friendly language constructs.
  7. There are hundreds of such plugins, each of which refers to various new Javascript features. These functions may or may not be part of the final Javascript specification. And if this never ends with a transition to the final Javascript specification, none of the browsers will implement this feature. So if any developer uses some experimental JS function using the babel plugin, this is the risk he / she takes. If this never ends in the specification, this piece of code should always be passed before it is deployed to browsers.
  8. This risk is subdivided into different levels to indicate the likelihood that a function will reach the final specification.
  9. Also, babel has grouped these plugins into different sets, which in terms of babel is called preset . And each preset contains plugins with different levels of risk.
  10. preset-0 This means that it has plugins for functions that are very experimental and therefore at high risk of reaching the final specification. This is similar to the idea that the developer came up with that Javascript should have a specific function, and he did some work to get it in the process of proposing TC-39.
  11. preset-1 It contains plugins for ideas about the features adopted by TC-39, and they think it's worth working on.
  12. preset-2 Plugins for functions for which a draft is ready. And it goes on ..

So it may happen that a function at stage 0 will reach stage 2 after some time and will eventually appear in the next release of Javascript.

Therefore, with each version of these Babel presets, you can find a different set of plugins in it. It may also happen that the function at stage 0 has undergone some changes and made significant changes to its functioning. And he reached, say, stage 2 with a completely different API. Therefore, developers must make sure that when they update these plugins, they make the necessary changes to their code.

+4
Sep 13 '18 at 10:28
source share

The original question "What is the difference between babel-preset-stage-0, babel-preset-stage-1, babel-preset-stage-2 and babel-preset-stage-3", it is strange that the answers focus on the "difference" between TC39 , step-0, step-1 .. the terminology "gains the right to vote, while the only relevant (although not exact) vote is down. To quote from Babel's website:

Babel Preset is a general list of plugins.

Official Babel Stage presets tracked the process of preparing the TC39 for new syntax sentences in JavaScript.

Each preset (for example, stage-3, stage-2, etc.) included all the plugins for this particular stage and add-ons over it. For example, step 2 includes step 3 and so on.

The main idea is "above it." I do not answer the second half, as the answers above are very good on this side.

+3
Mar 26 '19 at 3:20
source share

I have it. You guys can link https://babeljs.io/docs/plugins/preset-stage-0/

In a short word, preset-stage-0 contains all the functions that preset-stage-1 has, and preset-stage-1 contains all the functions that preset-stage-2 , etc ...

A lower number is more powerful. In your project, if you don’t worry about problems, just set stage-0 ...

-17
May 16 '16 at 10:48
source share



All Articles