EntrypointsOverSizeLimitWarning.js 971B

1234567891011121314151617181920212223242526272829
  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. super();
  11. this.name = "EntrypointsOverSizeLimitWarning";
  12. this.entrypoints = entrypoints;
  13. const entrypointList = this.entrypoints.map(entrypoint => `\n ${
  14. entrypoint.name
  15. } (${
  16. SizeFormatHelpers.formatSize(entrypoint.size)
  17. })\n${
  18. entrypoint.files.map(asset => ` ${asset}`).join("\n")
  19. }`).join("");
  20. this.message = `entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (${SizeFormatHelpers.formatSize(entrypointLimit)}). This can impact web performance.
  21. Entrypoints:${entrypointList}\n`;
  22. Error.captureStackTrace(this, this.constructor);
  23. }
  24. };