Can you choose which ES6 features to transpile with Babel?

 ̄綄美尐妖づ 提交于 2020-01-03 13:36:50

问题


For example, is there an option to pass Babel to only transpile arrow functions, or let/const?

My use case is to remove transpiling for certain features as browsers widely support them.


回答1:


Yes, you can pass a whitelist option to specify specific transformations to run, or a blacklist to specific transformations to disable.

They are listed here: http://babeljs.io/docs/advanced/transformers/. See also: http://babeljs.io/docs/usage/options/

Update:

The answer above applies to Babel 5. In Babel 6, all plugins are explicitly enabled either directly or via "presets" which bundle plugins together. You cannot blacklist specific plugins, but you may list only the plugins you want, excluding the ones you do not wish to run.



来源:https://stackoverflow.com/questions/31079261/can-you-choose-which-es6-features-to-transpile-with-babel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!