Trying to use webpack code splits with uglify. webpack emits code like this:
function(module, exports, __webpack_require__) {
/*global document: false, require: false, __webpack_public_path__: true */
'use strict';
var config = __webpack_require__(1);
__webpack_require__.p = config.baseurl;
if (document.location.pathname.match(/datapages\/$/)) {
__webpack_require__.e/* nsure */(1, function () {
!/* require */(/* empty */[__webpack_require__(2)]);
});
} else if (document.location.pathname.match(/hub\/$/)) {
__webpack_require__.e/* nsure */(2, function () {
!/* require */(/* empty */[__webpack_require__(4)]);
});
...
Uglify drops the contents of the inner functions:
function(t, n, e) {
"use strict";
var a = e(1);
e.p = a.baseurl, document.location.pathname.match(/datapages\/$/) ?
e.e(1, function() {}) : document.location.pathname.match(/hub\/$/) ?
e.e(2, function() {}) : ...
and emits warnings:
WARNING in main.js from UglifyJs
Dropping side-effect-free statement [./js/bogorouter.js:7,2]
Dropping side-effect-free statement [./js/bogorouter.js:11,2]
Dropping side-effect-free statement [./js/bogorouter.js:20,2]
Why does it think the __webpack_require__() calls are not side-effecting? They are.