IssueWebpackError.js 1.1 KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const path_1 = require("path");
  7. const IssueLocation_1 = require("./IssueLocation");
  8. const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
  9. class IssueWebpackError extends Error {
  10. constructor(message, issue) {
  11. super(message);
  12. this.issue = issue;
  13. this.hideStack = true;
  14. // to display issue location using `loc` property, webpack requires `error.module` which
  15. // should be a NormalModule instance.
  16. // to avoid such a dependency, we do a workaround - error.file will contain formatted location instead
  17. if (issue.file) {
  18. this.file = forwardSlash_1.default(path_1.relative(process.cwd(), issue.file));
  19. if (issue.location) {
  20. this.file += `:${IssueLocation_1.formatIssueLocation(issue.location)}`;
  21. }
  22. }
  23. Error.captureStackTrace(this, this.constructor);
  24. }
  25. }
  26. exports.IssueWebpackError = IssueWebpackError;