2016-11-06 00:08:58 +08:00
/ *
MIT License http : //www.opensource.org/licenses/mit-license.php
2016-11-06 00:43:03 +08:00
Author Sean Larkin @ thelarkinn
2016-11-06 00:08:58 +08:00
* /
2016-12-14 18:33:57 +08:00
var SizeFormatHelpers = require ( "../SizeFormatHelpers" ) ;
2016-11-29 23:32:10 +08:00
2016-12-14 18:33:57 +08:00
function EntrypointsOverSizeLimitWarning ( entrypoints , entrypointLimit ) {
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 entrypointList = this . entrypoints . map ( function ( entrypoint ) {
2016-12-14 18:33:57 +08:00
return "\n " + entrypoint . name + " (" + SizeFormatHelpers . formatSize ( entrypoint . size ) + ")\n" +
entrypoint . files
. map ( function ( asset ) {
return " " + asset + "\n" ;
2016-11-06 00:41:39 +08:00
} ) . join ( "" ) ;
} ) . join ( "" ) ;
2016-11-06 00:08:58 +08:00
2016-11-29 23:45:03 +08:00
this . message = "entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (" + SizeFormatHelpers . formatSize ( entrypointLimit ) + "). " +
2016-11-06 00:41:39 +08:00
"This can impact web performance.\n" +
2016-12-01 12:37:14 +08:00
"Entrypoints:" + entrypointList ;
2016-11-06 00:08:58 +08:00
}
module . exports = EntrypointsOverSizeLimitWarning ;
EntrypointsOverSizeLimitWarning . prototype = Object . create ( Error . prototype ) ;
EntrypointsOverSizeLimitWarning . prototype . constructor = EntrypointsOverSizeLimitWarning ;