ConflictingResourceHintsWarning.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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} ConflictingResourceHintDetails
  9. * @property {string} parent the chunk group the directives were written in
  10. * @property {string} child the chunk group they point at
  11. */
  12. class ConflictingResourceHintsWarning extends WebpackError {
  13. /**
  14. * Creates an instance of ConflictingResourceHintsWarning.
  15. * @param {ConflictingResourceHintDetails[]} links the conflicting links, parent name first
  16. */
  17. constructor(links) {
  18. const list = links
  19. .map((link) => `\n ${link.parent} -> ${link.child}`)
  20. .join("");
  21. super(
  22. `conflicting resource hints: these chunks are asked for as both prefetch and preload from the same place:${list}\nThe two say opposite things: a preload fetches the chunk at high priority right away, while a prefetch asks for it at idle priority in case it is needed later. Keep 'webpackPreload' for what the page needs now and 'webpackPrefetch' for what it may need later, not both.\nFor more info visit https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules`
  23. );
  24. /** @type {string} */
  25. this.name = "ConflictingResourceHintsWarning";
  26. }
  27. }
  28. module.exports = ConflictingResourceHintsWarning;