UNPKG

1.08 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Sean Larkin @thelarkinn
4*/
5
6"use strict";
7
8const { formatSize } = require("../SizeFormatHelpers");
9const WebpackError = require("../WebpackError");
10
11/** @typedef {import("./SizeLimitsPlugin").EntrypointDetails} EntrypointDetails */
12
13module.exports = class EntrypointsOverSizeLimitWarning extends WebpackError {
14 /**
15 * @param {EntrypointDetails[]} entrypoints the entrypoints
16 * @param {number} entrypointLimit the size limit
17 */
18 constructor(entrypoints, entrypointLimit) {
19 const entrypointList = entrypoints
20 .map(
21 entrypoint =>
22 `\n ${entrypoint.name} (${formatSize(
23 entrypoint.size
24 )})\n${entrypoint.files.map(asset => ` ${asset}`).join("\n")}`
25 )
26 .join("");
27 super(`entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (${formatSize(
28 entrypointLimit
29 )}). This can impact web performance.
30Entrypoints:${entrypointList}\n`);
31
32 this.name = "EntrypointsOverSizeLimitWarning";
33 this.entrypoints = entrypoints;
34 }
35};