2016-11-06 00:08:58 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2016-11-06 00:41:39 +08:00
|
|
|
function EntrypointsOverSizeLimitWarning(entrypoints, compilation, formatSizeFn) {
|
2016-11-06 00:08:58 +08:00
|
|
|
Error.call(this);
|
|
|
|
Error.captureStackTrace(this, EntrypointsOverSizeLimitWarning);
|
|
|
|
this.name = "EntrypointsOverSizeLimitWarning";
|
|
|
|
this.entrypoints = entrypoints;
|
2016-11-06 00:41:39 +08:00
|
|
|
var formatSize = formatSizeFn;
|
2016-11-06 00:08:58 +08:00
|
|
|
|
2016-11-06 00:41:39 +08:00
|
|
|
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("");
|
2016-11-06 00:08:58 +08:00
|
|
|
|
2016-11-06 00:41:39 +08:00
|
|
|
this.message = "The following Entrypoints combined asset size exceeds the recommended limit. " +
|
|
|
|
"This can impact web performance.\n" +
|
2016-11-06 00:08:58 +08:00
|
|
|
"Entrypoints: \n" +
|
|
|
|
entrypointList;
|
|
|
|
}
|
|
|
|
module.exports = EntrypointsOverSizeLimitWarning;
|
|
|
|
|
|
|
|
EntrypointsOverSizeLimitWarning.prototype = Object.create(Error.prototype);
|
|
|
|
EntrypointsOverSizeLimitWarning.prototype.constructor = EntrypointsOverSizeLimitWarning;
|