webpack/lib/performance/EntrypointsOverSizeLimitWar...

29 lines
1.1 KiB
JavaScript
Raw Normal View History

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
function EntrypointsOverSizeLimitWarning(entrypoints, compilation, formatSizeFn) {
Error.call(this);
Error.captureStackTrace(this, EntrypointsOverSizeLimitWarning);
this.name = "EntrypointsOverSizeLimitWarning";
this.entrypoints = entrypoints;
var formatSize = formatSizeFn;
var entrypointList = this.entrypoints.map(function(entrypoint) {
return "\n " + entrypoint.name + ": " + formatSize(entrypoint.size).string + "\n" +
Object.keys(entrypoint.assets).map(function(assetKey) {
var asset = entrypoint.assets[assetKey];
return " " + asset.name + ": " + formatSize(asset.size).string + "\n";
}).join("");
}).join("");
this.message = "The following Entrypoints combined asset size exceeds the recommended limit. " +
"This can impact web performance.\n" +
"Entrypoints: \n" +
entrypointList;
}
module.exports = EntrypointsOverSizeLimitWarning;
EntrypointsOverSizeLimitWarning.prototype = Object.create(Error.prototype);
EntrypointsOverSizeLimitWarning.prototype.constructor = EntrypointsOverSizeLimitWarning;