reporter.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. /**
  3. * Copyright (c) 2015-present, Waysact Pty Ltd
  4. *
  5. * This source code is licensed under the MIT license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. Object.defineProperty(exports, "__esModule", { value: true });
  9. exports.Reporter = void 0;
  10. class Reporter {
  11. /**
  12. * @internal
  13. */
  14. constructor(compilation, pluginName) {
  15. /**
  16. * @internal
  17. */
  18. this.emittedMessages = new Set();
  19. this.compilation = compilation;
  20. this.pluginName = pluginName;
  21. }
  22. /**
  23. * @internal
  24. */
  25. emitMessage(messages, message) {
  26. messages.push(new Error(`${this.pluginName}: ${message}`));
  27. }
  28. /**
  29. * @internal
  30. */
  31. emitMessageOnce(messages, message) {
  32. if (!this.emittedMessages.has(message)) {
  33. this.emittedMessages.add(message);
  34. this.emitMessage(messages, message);
  35. }
  36. }
  37. /**
  38. * @internal
  39. */
  40. warnOnce(message) {
  41. this.emitMessageOnce(this.compilation.warnings, message);
  42. }
  43. /**
  44. * @internal
  45. */
  46. errorOnce(message) {
  47. this.emitMessageOnce(this.compilation.errors, message);
  48. }
  49. /**
  50. * @internal
  51. */
  52. error(message) {
  53. this.emitMessage(this.compilation.errors, message);
  54. }
  55. }
  56. exports.Reporter = Reporter;
  57. //# sourceMappingURL=reporter.js.map