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.
Babel is a JavaScript transpiler, meaning it converts a newer version of ECMAScript, such as ES9, to a standard version (ES5).
Absolutely can and do use ES6 W/O babel. All major browsers support the vast majority of features natively (see CanIUse.com), in fact, the only major feature not supported is the import/export of modules. For these, you still have to manually import your modules in the correct order using script tags in the HTML.
Babel is a transpiler because it translates JavaScript ES6 to JavaScript ES5. In contrast, a compiler translates source code from a higher level language to a lower level. An example of compilation would be C++ to machine code or Java to JVM bytecode.
Babel is a JavaScript compiler and not a webpack loader. It compiles (transpiles) higher JavaScript code (ES6+) to lower JavaScript code (such as ES5).
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/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With