Just some things to keep in mind when using babel.
In order for certain features to work they require certain polyfills. You can satisfy all Babel feature requirements by using the included polyfill.
You may alternatively selectively include what you need:
Feature | Requirements |
---|---|
Abstract References | Symbol |
Array destructuring | Symbol |
Async functions, Generators | regenerator runtime |
Comprehensions | Array.from |
For Of | Symbol , prototype[Symbol.iterator] |
Spread | Array.from |
Built-in classes such as Date
, Array
, DOM
etc cannot be properly subclassed
due to limitations in ES5.
Since Babel assumes that your code will be run in an ES5 environment it uses ES5 functions. So if you're using an environment that has limited or no support for ES5 such as lower versions of IE then using the es5-shim along with the Babel polyfill will add support for these methods.
If you're inheriting from a class then static properties are inherited from it via __proto__, this is widely supported but you may run into problems with much older browsers.
NOTE: __proto__
is not supported on IE <= 10 so static properties
will not be inherited. See the
protoToAssign for a possible work
around.
For classes that have super
s, the super class won't resolve correctly. You can
get around this by enabling loose mode for classes.
In IE8 Object.defineProperty
can only be used on DOM objects. This is
unfortunate as it's required to set getters and setters. Due to this if
you plan on supporting IE8 or below then the usage of getters and setters
isn't recommended.
Reference: MDN.
By default, when using modules with Babel a non-enumerable __esModule
property
is exported. This is done through the use of Object.defineProperty
which is
unsupported in IE8 and below. A workaround for this is to enable
loose mode - modules.