RedundantDynamicImportWarning.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  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. class RedundantDynamicImportWarning extends WebpackError {
  8. /**
  9. * Creates an instance of RedundantDynamicImportWarning.
  10. * @param {string[]} imports descriptions of the `import()` calls that split nothing
  11. */
  12. constructor(imports) {
  13. const list = imports.map((description) => `\n ${description}`).join("");
  14. super(
  15. `dynamic imports: ${
  16. imports.length === 1
  17. ? "an 'import()' targets a module already loaded where it runs"
  18. : "these 'import()' calls target modules already loaded where they run"
  19. }, so nothing is deferred:${list}\n'import()' only splits a module out when nothing already loaded pulls it in — a static 'import' of it in the same entrypoint cancels the split.\nFor more info visit https://webpack.js.org/guides/code-splitting/`
  20. );
  21. /** @type {string} */
  22. this.name = "RedundantDynamicImportWarning";
  23. }
  24. }
  25. module.exports = RedundantDynamicImportWarning;