Skip to content
Alexandre Morgaut edited this page Mar 3, 2017 · 2 revisions

Welcome to the babel-plugin-transform-class wiki!

Here few hints about this babel transform-class plugin

Polyfills

The most simple way to get the polyfills your target platform potentially needs with this plugin is probably to use Polyfill.io:

<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Object.create,Object.assign"></script>

But if your prefer to fully control your polyfills, here some resources

Object.create()

The minimum support of Object.create() as used by this plugin can be simply achieved via this little snippet:

if (!Object.create) {
  Object.create = function (prototype) {
    function F() {}
    F.prototype = prototype;
    return new F();
  }
}

or this variant using the previously non official but widely supported __proto__ property:

if (!Object.create) {
  Object.create = function (prototype) {
    return {__proto__: prototype};
  }
}

See also

Object.assign()

Here a very minimum Object.assign() polyfill as used by this plugin (with only 2 arguments support & no return value)

if (!Object.assign) {
  Object.assign = function(target, properties) {
    for (var key in properties) target[key] = properties[key];
  };
}
Clone this wiki locally