Babel transforms, helpers and polyfills

by Bran van der Meer

Configuring Babel 6 can be a little daunting for starters. Depending on what exact ES2015 features you are trying to transpile, you'll need transforms (plugins/presets), helpers, polyfills or a combination.

ES2015 consists of syntactic sugar, new internals and a revised standard library. In general you won't need to transform features that are standard library, but you will need to polyfill those. The syntactic sugar can mostly be transformed without the polyfill, but sometimes babel will need helpers for them.

The helpers can be automatically inlined during transforms (default behaviour), delivered separately as a runtime, or you can deliver them yourself with babel-plugin-external-helpers-2. It's up to you whether you want to use the entire babel-polyfill (about 90kb) package, or include separate polyfills. Actually, any working polyfill will do.

The table below specifies the requirements for all ES2015 features. List of features taken from es6-features.org.

Feature Sub-feature Transform Helpers Polyfill
Constants Constants required not necessary not necessary
Scoping Block-Scoped Variables required optional not necessary
Block-Scoped Functions required not necessary not necessary
Arrow Functions Expression Bodies required optional not necessary
Statement Bodies required optional not necessary
Lexical this required optional not necessary
Extended Parameter Handling Default Parameter Values required not necessary not necessary
Rest Parameter required required not necessary
Spread Operator required required not necessary
Template Literals String Interpolation required not necessary not necessary
Custom Interpolation required required not necessary
Raw String Access required required required
Extended Literals Binary & Octal Literal required not necessary not necessary
Unicode String & RegExp Literal required not necessary not necessary
Enhanced Regular Expression Regular Expression Sticky Matching not necessary not necessary required
Enhanced Object Properties Property Shorthand required not necessary not necessary
Computed Property Names required required not necessary
Method Properties required not necessary not necessary
Destructuring Assignment Array Matching required required not necessary
Object Matching, Shorthand Notation required not necessary not necessary
Object Matching, Deep Matching required not necessary not necessary
Parameter Context Matching required not necessary not necessary
Fail-Soft Destructuring required not necessary not necessary
Modules Value Export/Import required required not necessary
Default & Wildcard required not necessary not necessary
Classes Class Definition required required not necessary
Class Inheritance required required not necessary
Class Inheritance, From Expressions required not necessary not necessary
Base Class Access required required not necessary
Static Members required not necessary not necessary
Getter/Setter required not necessary not necessary
Symbol Type Symbol Type required required required
Global Symbols not necessary required required
Iterators Iterator & For-Of Operator required not necessary required
Generators Generator Function, Direct Use required not necessary required
Generator Function, Iterator Protocol required required required
Generator Matching required not necessary required
Generator Methods required not necessary required
Map/Set & WeakMap/WeakSet Set Data-Structure not necessary not necessary required
Map Data-Structure not necessary not necessary required
Weak-Link Data-Structures not necessary not necessary required
Typed Arrays Typed Arrays not necessary not necessary required
New Built-In Methods Object Property Assignment not necessary not necessary required
Array Element Finding not necessary not necessary required
String Repeating not necessary not necessary required
String Searching not necessary not necessary required
Number Type Checking not necessary not necessary required
Number Safety Checking not necessary not necessary required
Number Comparison not necessary not necessary required
Number Truncation not necessary not necessary required
Number Sign Determination not necessary not necessary required
Promises Promise Usage not necessary not necessary required
Promise Combination not necessary not necessary required
Meta-Programming Proxying not possible not possible not possible
Reflection not necessary not necessary required
Internationalization & Localization Collation not necessary not necessary required
Number Formatting not necessary not necessary required
Currency Formatting not necessary not necessary required
Date/Time Formatting not necessary not necessary required