class transpilation without extends does not facilitate tree shaking
Hi there,
So if you transpile this
class Foo {
foo () {}
}I get this:
var Foo = function Foo () {};
Foo.prototype.foo = function foo () {};which is a problem because during tree-shaking, Foo has to be included regardless since it creates a function at a global scope.
With extends, however, the output can be easily removed since it's something like:
// Input
class Foo2 extends Bar {
foo () {}
}
// Output
var Foo2 = (function (Bar) {
function Foo2 () {
Bar.apply(this, arguments);
}
if ( Bar ) Foo2.__proto__ = Bar;
Foo2.prototype = Object.create( Bar && Bar.prototype );
Foo2.prototype.constructor = Foo2;
Foo2.prototype.foo = function foo () {};
return Foo2;
}(Bar));which is an IIFE, which theoretically is the same, but those do get removed if Foo2 is not being used. Therefore, can we make the 2 outputs the same (which is the same behavior as babel)?