EntrypointsOverSizeLimitWarning.js 1.1 KB

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