Transpile Async Await proposal with Babel.js?

前端 未结 5 688
耶瑟儿~
耶瑟儿~ 2020-11-30 21:08

There is a proposal for introducing C# style async-await. I know Babel.js transpiles ES6 to ES5, but is there any way to make it transpile async-await to

5条回答
  •  臣服心动
    2020-11-30 21:50

    The approved answer seems to be outdated now. The experimental flag has been deprecated in favor of stage.

    http://babeljs.io/blog/2015/03/31/5.0.0/#experimental-option

    Usage

    $ babel --stage 0
    

    babel.transform("code", { stage: 0 });
    

    Stage 0

    • es7.classProperties
    • es7.comprehensions

    Stage 1

    • es7.asyncFunctions
    • es7.decorators
    • es7.exportExtensions
    • es7.objectRestSpread

    Stage 2 (Stage 2 and above are enabled by default)

    • es7.exponentiationOperator

提交回复
热议问题