Programming

babel-preset-stage-0, babel-preset-stage-1 등의 차이점은 무엇입니까?

procodes 2020. 7. 17. 21:37
반응형

babel-preset-stage-0, babel-preset-stage-1 등의 차이점은 무엇입니까?


내 질문은 : 차이 무엇인가 babel-preset-stage-0, babel-preset-stage-1, babel-preset-stage-2babel-preset-stage-3,와 우리가 개발 최선의 선택은 무엇을 ES6?


Babel의 단계 사전 설정은 TC39 프로세스 및 잠재적 언어 변경에 대한 각 제안의 다른 상태와 동일합니다 . 여기에는 해당 단계에서 제안 된 모든 변경 사항에 대한 구현 및 폴리 필이 포함됩니다.

현재 ES6이 아닌Stage-0 Strawman이 있습니다. 미래의 Javascript이며 공식 ECMAScript 사양으로 만들지 확실하지 않습니다.

이 결과를 이해하지 않고 작동하도록 설정stage-0 하지 마십시오 .

ES6 기능 만 포함 된 Babel Preset은 preset-es2015


대부분 다른 답변으로 정교합니다. 4 단계가 가장 안정적이며 0 단계가 가장 위험합니다. 다음은 이전 답변과 설명서의 5 단계에 대한 간략한 설명입니다. 나는 이것에 왔을 때 각 단계가 무엇인지에 대한 더 높은 수준의 분석을 기대했기 때문에 이것을 추가하고 있습니다.


4 단계 : 완료

ECMAScript Standard에 포함 준비 완료, 테스트 통과 및 다음 개정의 일부


3 단계 : 후보

전체 사양 텍스트를 포함하고 대부분 테스트 및 피드백과 함께 제공되는 플러그인을 포함합니다. 솔루션이 완성되었으며 모든 추가 변경 사항은 구현 경험을 기반으로합니다.


2 단계 : 초안

플러그인에 대한 추가 지원이 가능한 많이 완료되었습니다. 이에 대한 요구 사항은 대부분 점차적으로 변경 사항 만 충족합니다. 의미 및 API가 완료 될 것으로 예상됩니다. 아마도 사양의 일부가 될 것입니다.


1 단계 : 제안 이 단계에서 발견되고 검토 될 개념은 대부분 폴리 필과 데모로 예상됩니다.


0 단계 : Strawman 이 이름은 TC-39에 따라 일종의 구속력이 없지만 상황에 따라 후속 작업이나 조사 대상으로 선정되지 않은 개념의 범주입니다.

각 레벨은 포괄적 인 반면 4는 3에 2를 포함합니다.이 합계가 미래의 누군가를 돕기를 바랍니다.


이 단계는 TC39 프로세스에 의해 정의 된대로 단계적이지만 유용한 아이디어에서 ES6와 같은 수용 가능한 표준으로 기능을 작동시킵니다. 모든 코너 케이스에 대해 논의하고, 생각하고, 테스트하고, polyfilled하고, 더 많은 것을 논의 해야하는 등의 과정으로 인해 시간이 걸립니다. 즉, 표준 기관입니다. 목표는 "ES5"를 말하는 것과 마찬가지로 "ES6"을 말하는 것은 온전하고 완전한 의미를 갖습니다.

실제로, 프로젝트 요구 사항은 유지하기 위해 노력하는 것부터 사실에 이르기까지 매우 편리한 언어 기능을 사용하는 것이 좋습니다. 다음 링크로 시작하고 싶을 것입니다.

  • TC39 프로세스 개요 : 여기에는 단계의 의미와 기능이 단계마다 어떻게 진행되는지에 대한 멋진 차트가 포함되어 있습니다. 아래는 TC39의 개요입니다.

  • 진행중인 제안서 : 특정 제안서의 단계에 대한 간단한 개요. 또한 완성 된, 비활성 및 단계 0 제안서에 대한 링크도 포함합니다. 2017 년 4 월 현재, Public Class Fields는 2 단계에 있습니다. 즉, 정확하게 설명되고 검토자가 배정되었지만 완전히 검토되지는 않았습니다.

  • 3 단계 용 Babel 사전 설정 패키지 : 모든 3 단계 제안에 대해 Git 및 NPM에 대한 링크가있는 플러그인 페이지. 기본적으로이 플러그인은 이론적으로 TC39 3 단계의 현재 제안을 폴리 필하는 패키지 모음을 가져옵니다. 실제로 버그가 발생할 수 있습니다. 또한 비슷한 것을 찾을 수 있습니다. 마찬가지로 2 단계 이하 의 플러그인 페이지에 연결 됩니다. 해당 페이지는 3 단계 제안서와 덜 안정적인 제안서가 모두 포함 된 패키지로 연결됩니다.

  • Babel Preset 'env' :이 Babel 프리셋은 완성 된 제안을 지원하여 알려진 환경에서 이러한 기능을 지원하는 데 필요한 올바른 패키지를 선택합니다. 예를 들어 로컬 node실행 파일은 이전 브라우저보다 플러그인이 더 적습니다. 승인 된 향후 기능을 지원하는 'stage-4'플러그인을 생각할 수 있습니다.

요약하면 이러한 시험판 기능을 사용하는 경우에만 처리하면됩니다. 그것들을 사용해야 할 필요가 있다면, 가장 많은 수의 스테이지를 선택하십시오. 워터 쿨러 주변에서 토론 할 수있는 미친 기능을 갖춘 장난감 설치를 원한다면 0 단계를 진행하십시오.


이것이 가장 이해하기 좋은 출발점입니다. 바벨 프리셋이란?

링크에서 발췌 :

Stage 0-Strawman : 아이디어, 가능한 Babel 플러그인.
1 단계-제안 : 작업 할 가치가 있습니다.
2 단계-초안 : 초기 사양.
3 단계-후보 : 전체 사양 및 초기 브라우저 구현.
4 단계-완료 : 다음 해 릴리스에 추가됩니다.

전체 사진 :

  1. 시간이 지남에 따라 Javascript가 발전하고 점점 더 많은 기능이 언어에 추가되고 있습니다.
  2. 브라우저는 이러한 새로운 기능을 구현하여 이해할 수 있도록 많은 작업을 수행해야합니다. 이 프로세스는 일반적으로 Javascript가 발전하는 속도보다 훨씬 느립니다.
  3. 그러나 개발자는 코드를보다 쉽게 ​​작성, 이해 및 유지 관리 할 수 ​​있도록 새로운 언어 기능을 사용하려고합니다.
  4. So developers write their code using the new Javascript features, but before that code reaches browsers, it goes through a build process where using some magic, all the code with new features is transpiled into code understandable by browser. i.e. new features of Javascript but coded using the browser understandable constructs of language.
  5. The build magic can be performed using tools, one of them being Babel.
  6. The way Babel works is that it takes a set of plugins. Each of these plugin could refer to transforming a particular new feature of Javscript into browser understandable constructs of language.
  7. There are hundreds of such plugins, each one referring to different new features of Javascript. These features may or may not be part of the final Javascript spec. And if it never ends up going to final Javascript spec, none of the browsers will implement this feature. So if any developer uses any experimental feature of JS using babel plugin, its the risk that he/she is taking. If it never ends up in spec, that part of code will always have to be transpiled before its deployed to browsers.
  8. This risk is categorised into various levels to signify the chances of any feature reaching the final spec.
  9. Also babel has grouped these plugins into various sets, which is called a preset in babel's terms. And each preset contains plugins from various levels of risk.
  10. 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.
  11. preset-1 It contains the plugins for the feature ideas accepted by the TC-39, and they find it worth working on.
  12. 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.


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.


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

In a short word, preset-stage-0 contains all the functionality that preset-stage-1 has, and preset-stage-1 contains all the functionality that preset-stage-2 has and so on...

Lower digit is more powerful. In your project, If you don't wanner bother with problems, just set stage-0...

참고URL : https://stackoverflow.com/questions/37251552/whats-the-difference-between-babel-preset-stage-0-babel-preset-stage-1-etc

반응형