ModuleDependencyWarning.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const WebpackError = require("./WebpackError");
  7. const makeSerializable = require("./util/makeSerializable");
  8. /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
  9. /** @typedef {import("./Module")} Module */
  10. class ModuleDependencyWarning extends WebpackError {
  11. /**
  12. * @param {Module} module module tied to dependency
  13. * @param {Error} err error thrown
  14. * @param {DependencyLocation} loc location of dependency
  15. */
  16. constructor(module, err, loc) {
  17. super(err ? err.message : "");
  18. this.name = "ModuleDependencyWarning";
  19. this.details =
  20. err && !(/** @type {any} */ (err).hideStack)
  21. ? /** @type {string} */ (err.stack).split("\n").slice(1).join("\n")
  22. : undefined;
  23. this.module = module;
  24. this.loc = loc;
  25. /** error is not (de)serialized, so it might be undefined after deserialization */
  26. this.error = err;
  27. if (err && /** @type {any} */ (err).hideStack) {
  28. this.stack =
  29. /** @type {string} */ (err.stack).split("\n").slice(1).join("\n") +
  30. "\n\n" +
  31. this.stack;
  32. }
  33. }
  34. }
  35. makeSerializable(
  36. ModuleDependencyWarning,
  37. "webpack/lib/ModuleDependencyWarning"
  38. );
  39. module.exports = ModuleDependencyWarning;