[英]Which Babel transformers should I blacklist for a Chrome app?
I'm writing ES6+ code and compiling it with Babel (currently using {stage: 0}
as my .babelrc
config). 我正在编写ES6 +代码,并用Babel编译(当前使用
{stage: 0}
作为我的.babelrc
配置)。
So I'm compiling everything right down to ES5. 因此,我正在编译所有内容,直到ES5。 But I'm exlusively targeting Chrome v47+, which supports some ES6+ features natively.
但是我专门针对Chrome v47 +,它本身就支持某些ES6 +功能。
Which of the default Babel transformers can I blacklist (disable) and still have my code run in Chrome 47+? 我可以将哪些默认的Babel变压器列入黑名单(禁用),并且仍然可以在Chrome 47+中运行我的代码?
Take a look at this page to see what features are fully implemented and enabled by default in Chrome and this page for the Babel transformers to which they correspond. 查看此页面,以查看Chrome默认情况下完全实现并启用了哪些功能,以及此页面对应的Babel变压器。
ES6 Feature Release Babel Transformer Spec. Compliant*
--------------------------------------------------------------------------------------
Rest Parameters | 47 | es6.parameters | ✔
Spread | 46 | es6.spread | ✔
Arrow Functions | 45 | es6.arrowFunctions | ✔
Extended Obj. Literals | 45 | es6.properties.shorthand/computed | ✘
Computed Prop. Names | 44 | es6.properties.shorthand/computed | ✘
Classes | 42 | es6.classes | ✘
Template Strings | 41 | es6.templateLiterals | ✘
Generators | 39 | regenerator | ✘
JS iterators | 38 | es6.forOf | ✘
Block bindings | 18 | es6.blockScoping/constants | ✘
*I have derived the column Spec. *我导出了Spec列。 Compliant (re: Chrome not Babel) by looking at what draft of the specification the current implementation is based.
通过查看当前实现所基于的规范草案来兼容(例如:Chrome不是Babel)。 For example 'Editor's Draft' -- I assume this means a potentially incomplete or incorrect implementation.
例如“编辑草稿”-我认为这意味着潜在的不完整或不正确的实现。
______ ______
These are the dependencies that transformers have on each other that I have identified from the Babel source code: 这些是我从Babel源代码中识别出的变压器相互之间的依赖关系:
Transformer Dependencies
--------------------------------------------
es7.classProperties | es6.classes
es7.decorators | es6.classes
es7.asyncFunctions | es6.classes
es7.objectRestSpread | es6.destructuring
______ ______
It seems that no ES6 Babel transformer is dependent on another. 似乎没有ES6 Babel变压器依赖于另一个。 So, any ES6 feature that is implemented in Chrome, and is spec.
因此,Chrome中实现的任何ES6功能都是规范的。 compliant , you no longer need to rely on Babel for.
兼容 ,您不再需要依赖Babel。 And these are:
es6.parameters
, es6.spread
, and es6.arrowFunctions
. 它们是:
es6.parameters
, es6.spread
和es6.arrowFunctions
。
It's currently not quite as simple as disabling transformers for features the environment supports, because some transformers have dependencies on others. 目前,它还不像为环境所支持的功能禁用转换器那样简单,因为某些转换器依赖于其他转换器。 For example, the
es7.asyncFunctions
transformer depends on es6.classes
, even for environments where classes are natively supported. 例如,即使对于本地支持类的环境,
es7.asyncFunctions
转换器也依赖于es6.classes
。 By "depends", I don't mean that es7.asyncFunctions
automatically invokes es6.classes
, I mean that es6.classes
has to be individually enabled (either explicitly or by not being blacklisted). “依赖”不是指
es7.asyncFunctions
自动调用es6.classes
,而是指es6.classes
必须单独启用(无论是显式还是不被列入黑名单)。 See babel/babel#2415 . 参见babel / babel#2415 。
Possibly also of interest: babel/babel#2340 . 可能还感兴趣: babel / babel#2340 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.