EvalUsageWarning.js 1.0 KB

12345678910111213141516171819202122232425262728
  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 EvalUsageWarning extends WebpackError {
  8. /**
  9. * Creates an instance of EvalUsageWarning.
  10. * @param {string[]} modules the modules calling it, named for the report
  11. * @param {number} total how many call it in all
  12. */
  13. constructor(modules, total) {
  14. const list = modules.map((module) => `\n ${module}`).join("");
  15. super(
  16. `eval usage: ${total} ${total === 1 ? "module calls" : "modules call"} 'eval' directly:${list}\nA direct eval reads and writes any name in scope, so nothing the module declares can be renamed or dropped: minification, scope hoisting and tree shaking all stop at it. 'new Function' takes no local scope and does not.\nFor more info visit https://webpack.js.org/configuration/optimization/#optimizationconcatenatemodules`
  17. );
  18. /** @type {string} */
  19. this.name = "EvalUsageWarning";
  20. }
  21. }
  22. module.exports = EvalUsageWarning;