SplitChunksCappedWarning.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Alexander Akait @alexander-akait
  4. */
  5. "use strict";
  6. const WebpackError = require("./WebpackError");
  7. /**
  8. * @typedef {object} CappedSplitDetails
  9. * @property {string} cacheGroup the cache group whose split was refused
  10. * @property {string} chunk the chunk it would have been taken out of
  11. * @property {string} limit the option that refused it
  12. * @property {number} maxRequests the value that option had
  13. * @property {number} modules how many modules the split would have moved
  14. */
  15. class SplitChunksCappedWarning extends WebpackError {
  16. /**
  17. * Creates an instance of SplitChunksCappedWarning.
  18. * @param {CappedSplitDetails[]} splits the refused splits, most modules first
  19. */
  20. constructor(splits) {
  21. const list = splits
  22. .map(
  23. (split) =>
  24. `\n cacheGroup '${split.cacheGroup}' out of ${split.chunk} (${split.modules} modules, ${split.limit} is ${split.maxRequests})`
  25. )
  26. .join("");
  27. super(
  28. `split chunks capped: 'optimization.splitChunks' refused these splits because the chunk already had as many requests as it is allowed:${list}\nThe modules stayed where they were, so the cache group did not take effect. Raising the limit lets the split happen, at the cost of more parallel requests.\nFor more info visit https://webpack.js.org/plugins/split-chunks-plugin/`
  29. );
  30. /** @type {string} */
  31. this.name = "SplitChunksCappedWarning";
  32. }
  33. }
  34. module.exports = SplitChunksCappedWarning;