Skip to content

Instantly share code, notes, and snippets.

@arackaf
Last active February 26, 2018 08:05
Show Gist options
  • Save arackaf/130aa3213d033229d20ae86741a96e6a to your computer and use it in GitHub Desktop.
Save arackaf/130aa3213d033229d20ae86741a96e6a to your computer and use it in GitHub Desktop.
//entry point
import Class1 from "./junk1";
import Class2 from "./junk2";
import Class3 from "./junk3";
export default function() {
let a = new Class1();
let b = new Class2();
let c = new Class3();
return a.junk() + b.junk() + c.junk();
}
//junk1.js
export default class {
junk() {
return Math.random() + 1;
}
}
//junk2.js
export default class {
junk() {
return Math.random() + 2;
}
}
//junk3.js
export default class {
junk() {
return Math.random() + 3;
}
}
//webpack 3 output (in part)
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
// CONCATENATED MODULE: ./junk1.js
let _default = class _default {
junk() {
return Math.random() + 1;
}
};
// CONCATENATED MODULE: ./junk2.js
let junk2__default = class _default {
junk() {
return Math.random() + 2;
}
};
// CONCATENATED MODULE: ./junk3.js
let junk3__default = class _default {
junk() {
return Math.random() + 3;
}
};
// CONCATENATED MODULE: ./tempMain.js
/* harmony default export */ __webpack_exports__["default"] = (function () {
let a = new _default();
let b = new junk2__default();
let c = new junk3__default();
return a.junk() + b.junk() + c.junk();
});
/***/ })
//webpack 4 output, in part
function(n, e, r) {
"use strict";
r.r(e),
(e.default = function() {
let n = new class {
junk() {
return Math.random() + 1;
}
}(),
e = new class {
junk() {
return Math.random() + 2;
}
}(),
r = new class {
junk() {
return Math.random() + 3;
}
}();
return n.junk() + e.junk() + r.junk();
});
// ------------------------------------------------------------------------
//WHOA - it inlined the whole class. Let's see if we can force a more normal behavior
//new entry point
import Class1 from "./junk1";
import Class2 from "./junk2";
import Class3 from "./junk3";
export function Hello() {
return Math.random() > 0.5 ? new Class1() : Math.random > 0.25 ? new Class2() : new Class3();
}
export default function() {
let a = new Class1();
let b = new Class2();
let c = new Class3();
return a.junk() + b.junk() + c.junk();
}
//webpack 3 output (in part) - it's not minified - DON'T focus on the long variable names - focus on how each
//thing is defined in like 3 different places
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["Hello"] = Hello;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__junk1__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__junk2__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__junk3__ = __webpack_require__(3);
function Hello() {
return Math.random() > 0.5 ? new __WEBPACK_IMPORTED_MODULE_0__junk1__["a" /* default */]() : Math.random > 0.25 ? new __WEBPACK_IMPORTED_MODULE_1__junk2__["a" /* default */]() : new __WEBPACK_IMPORTED_MODULE_2__junk3__["a" /* default */]();
}
/* harmony default export */ __webpack_exports__["default"] = (function () {
let a = new __WEBPACK_IMPORTED_MODULE_0__junk1__["a" /* default */]();
let b = new __WEBPACK_IMPORTED_MODULE_1__junk2__["a" /* default */]();
let c = new __WEBPACK_IMPORTED_MODULE_2__junk3__["a" /* default */]();
return a.junk() + b.junk() + c.junk();
});
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _default; });
let _default = class _default {
junk() {
return Math.random() + 1;
}
};
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _default; });
let _default = class _default {
junk() {
return Math.random() + 2;
}
};
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _default; });
let _default = class _default {
junk() {
return Math.random() + 3;
}
};
/***/ })
/******/ ]);
//webpack 4 output (in part) - SOOOOOOO MUCH CLEANER!!!!!
function(n, e, r) {
"use strict";
r.r(e);
let t = class {
junk() {
return Math.random() + 1;
}
},
u = class {
junk() {
return Math.random() + 2;
}
},
o = class {
junk() {
return Math.random() + 3;
}
};
function a() {
return Math.random() > 0.5 ? new t() : Math.random > 0.25 ? new u() : new o();
}
r.d(e, "Hello", function() {
return a;
}),
(e.default = function() {
let n = new t(),
e = new u(),
r = new o();
return n.junk() + e.junk() + r.junk();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment