DynamicExportsWarning.js 1.0 KB

123456789101112131415161718192021222324252627282930
  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. /** @typedef {{ name: string, size: number }} DynamicExportsDetails */
  8. class DynamicExportsWarning extends WebpackError {
  9. /**
  10. * Creates an instance of DynamicExportsWarning.
  11. * @param {DynamicExportsDetails[]} modules the modules to name, largest first
  12. * @param {number} total how many were found
  13. */
  14. constructor(modules, total) {
  15. super(
  16. `dynamic exports: webpack cannot tell what ${total} ${total === 1 ? "module exports" : "modules export"}, so nothing importing ${total === 1 ? "it" : "them"} can be tree-shaken:
  17. ${modules.map(({ name, size }) => ` ${name} (${size} bytes)`).join("\n")}
  18. Exports assigned under a condition or through a computed key cannot be read statically. For more info visit https://webpack.js.org/guides/tree-shaking/`
  19. );
  20. this.name = "DynamicExportsWarning";
  21. }
  22. }
  23. module.exports = DynamicExportsWarning;