Last active
January 20, 2017 23:56
-
-
Save jouni-kantola/e5270bea7ab50b361419da164ee01c81 to your computer and use it in GitHub Desktop.
webpack class tree shaking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
import { OneNumber } from './deps/class-tree-shaking.js'; | |
// class-tree-shaking.js | |
class Math { | |
static multiply(a, b) { | |
return a * b; | |
} | |
get sum() { | |
return this.first + this.second; | |
} | |
_subtract(second, first) { | |
return second - first; | |
} | |
} | |
class TwoNumbers extends Math { | |
constructor(first, second) { | |
super(); | |
this.first = first; | |
this.second = second; | |
} | |
} | |
class OneNumber { | |
constructor(a) { | |
this.a = a; | |
} | |
get valueOfOneNumber() { | |
return this.a; | |
} | |
} | |
export default { OneNumber, TwoNumbers }; | |
export const aNumber = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([1, 2], { | |
"4Hfm": function(t, e, n) { | |
"use strict"; | |
function r(t, e) { | |
if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | |
return !e || "object" != typeof e && "function" != typeof e ? t : e | |
} | |
function o(t, e) { | |
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function, not " + typeof e); | |
t.prototype = Object.create(e && e.prototype, { | |
constructor: { | |
value: t, | |
enumerable: !1, | |
writable: !0, | |
configurable: !0 | |
} | |
}), e && (Object.setPrototypeOf ? Object.setPrototypeOf(t, e) : t.__proto__ = e) | |
} | |
function u(t, e) { | |
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") | |
} | |
var i = function() { | |
function t(t, e) { | |
for (var n = 0; n < e.length; n++) { | |
var r = e[n]; | |
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, r.key, r) | |
} | |
} | |
return function(e, n, r) { | |
return n && t(e.prototype, n), r && t(e, r), e | |
} | |
}(), | |
c = function() { | |
function t() { | |
u(this, t) | |
} | |
return i(t, [{ | |
key: "_subtract", | |
value: function(t, e) { | |
return t - e | |
} | |
}, { | |
key: "sum", | |
get: function() { | |
return this.first + this.second | |
} | |
}], [{ | |
key: "multiply", | |
value: function(t, e) { | |
return t * e | |
} | |
}]), t | |
}(); | |
(function(t) { | |
function e(t, n) { | |
u(this, e); | |
var o = r(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this)); | |
return o.first = t, o.second = n, o | |
} | |
return o(e, t), e | |
})(c), | |
function() { | |
function t(e) { | |
u(this, t), this.a = e | |
} | |
return i(t, [{ | |
key: "valueOfOneNumber", | |
get: function() { | |
return this.a | |
} | |
}]), t | |
}() | |
}, | |
lVK7: function(t, e, n) { | |
"use strict"; | |
Object.defineProperty(e, "__esModule", { | |
value: !0 | |
}); | |
n("4Hfm") | |
} | |
}, ["lVK7"]); | |
//# sourceMappingURL=app.af0694bb1621f518ae01.prod.js.map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([1,2],{ | |
/***/ "4Hfm": | |
/***/ (function(module, __webpack_exports__, __webpack_require__) { | |
"use strict"; | |
/* unused harmony export aNumber */ | |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var Math = function () { | |
function Math() { | |
_classCallCheck(this, Math); | |
} | |
_createClass(Math, [{ | |
key: "_subtract", | |
value: function _subtract(second, first) { | |
return second - first; | |
} | |
}, { | |
key: "sum", | |
get: function get() { | |
return this.first + this.second; | |
} | |
}], [{ | |
key: "multiply", | |
value: function multiply(a, b) { | |
return a * b; | |
} | |
}]); | |
return Math; | |
}(); | |
var TwoNumbers = function (_Math) { | |
_inherits(TwoNumbers, _Math); | |
function TwoNumbers(first, second) { | |
_classCallCheck(this, TwoNumbers); | |
var _this = _possibleConstructorReturn(this, (TwoNumbers.__proto__ || Object.getPrototypeOf(TwoNumbers)).call(this)); | |
_this.first = first; | |
_this.second = second; | |
return _this; | |
} | |
return TwoNumbers; | |
}(Math); | |
var OneNumber = function () { | |
function OneNumber(a) { | |
_classCallCheck(this, OneNumber); | |
this.a = a; | |
} | |
_createClass(OneNumber, [{ | |
key: "valueOfOneNumber", | |
get: function get() { | |
return this.a; | |
} | |
}]); | |
return OneNumber; | |
}(); | |
/* unused harmony default export */ var _unused_webpack_default_export = { OneNumber: OneNumber, TwoNumbers: TwoNumbers }; | |
var aNumber = 2; | |
/***/ }), | |
/***/ "lVK7": | |
/***/ (function(module, __webpack_exports__, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | |
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__deps_class_tree_shaking_js__ = __webpack_require__("4Hfm"); | |
/***/ }) | |
},["lVK7"]); | |
//# sourceMappingURL=app.af0694bb1621f518ae01.dev.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment