简体   繁体   中英

Can you choose which ES6 features to transpile with Babel?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM