error-loader.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
  7. var _path = _interopRequireDefault(require("path"));
  8. function _interopRequireDefault(obj) {
  9. return obj && obj.__esModule ? obj : {
  10. default: obj
  11. };
  12. }
  13. const ErrorLoader = function() {
  14. var ref, ref1, ref2;
  15. // @ts-ignore exists
  16. const options = this.getOptions() || {};
  17. const { reason ="An unknown error has occurred" } = options;
  18. var ref3;
  19. // @ts-expect-error
  20. const resource = (ref3 = (ref = this._module) == null ? void 0 : (ref1 = ref.issuer) == null ? void 0 : ref1.resource) != null ? ref3 : null;
  21. var _rootContext;
  22. const context = (_rootContext = this.rootContext) != null ? _rootContext : (ref2 = this._compiler) == null ? void 0 : ref2.context;
  23. const issuer = resource ? context ? _path.default.relative(context, resource) : resource : null;
  24. const err = new Error(reason + (issuer ? `\nLocation: ${_chalk.default.cyan(issuer)}` : ""));
  25. this.emitError(err);
  26. };
  27. var _default = ErrorLoader;
  28. exports.default = _default;
  29. //# sourceMappingURL=error-loader.js.map