607fca8a0161a2b89673eebac09f724f3c545c89ccee7e46b136080c190f68b7c5e42e4bde0fd11d5f4c6f4214484eb120db7993f0b455de96829a4af62960 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. const extractError = require('./extractWebpackError');
  3. /**
  4. * Applies all transformers to all errors and returns "annotated"
  5. * errors.
  6. *
  7. * Each transformer should have the following signature WebpackError => AnnotatedError
  8. *
  9. * A WebpackError has the following fields:
  10. * - message
  11. * - file
  12. * - origin
  13. * - name
  14. * - severity
  15. * - webpackError (original error)
  16. *
  17. * An AnnotatedError should be an extension (Object.assign) of the WebpackError
  18. * and add whatever information is convenient for formatting.
  19. * In particular, they should have a 'priority' field.
  20. *
  21. * The plugin will only display errors having maximum priority at the same time.
  22. *
  23. * If they don't have a 'type' field, the will be handled by the default formatter.
  24. */
  25. function processErrors (errors, transformers) {
  26. const transform = (error, transformer) => transformer(error);
  27. const applyTransformations = (error) => transformers.reduce(transform, error);
  28. return errors.map(extractError).map(applyTransformations);
  29. }
  30. module.exports = processErrors;