EntrypointsOverSizeLimitWarning.js 968 B

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