Friday, March 31, 2017

Webpack: There's some JavaScript code in the compiled file even when the source file is empty

I'm using Laravel and Laravel Mix. Out of the box, the included app.js file bootstraps quite a few dependencies like jQuery, Bootstrap-sass etc.

When I delete everything in the app.js file, why is there still some code in the compiled js file? Is it a Webpack thing? Even after running npm run production it stays there and I haven't been able to figure out what it does or what it means and not knowing makes me really uncomfortable.

Here's the code that gets left behind:

! function(n) {
function t(e) {
    if (r[e]) return r[e].exports;
    var o = r[e] = {
        i: e,
        l: !1,
        exports: {}
    };
    return n[e].call(o.exports, o, o.exports, t), o.l = !0, o.exports
}
var r = {};
t.m = n, t.c = r, t.i = function(n) {
    return n
}, t.d = function(n, r, e) {
    t.o(n, r) || Object.defineProperty(n, r, {
        configurable: !1,
        enumerable: !0,
        get: e
    })
}, t.n = function(n) {
    var r = n && n.__esModule ? function() {
        return n.default
    } : function() {
        return n
    };
    return t.d(r, "a", r), r
}, t.o = function(n, t) {
    return Object.prototype.hasOwnProperty.call(n, t)
}, t.p = "", t(t.s = 3)
}([function(n, t) {}, function(n, t) {}, function(n, t) {}, function(n, t, r) {
r(0), r(1), n.exports = r(2)
}]);



via Mav

Advertisement