function formatWebpackErrors(errors) {
  let formattedErrors = errors.map(function (errorObjOrMessage) {
    // Webpack 5 compilation errors are in the form of descriptor objects,
    // so we have to join pieces to get the format we want.
    if (typeof errorObjOrMessage === `object`) {
      return formatMessage(
        [errorObjOrMessage.moduleName, errorObjOrMessage.message].join(`\n`)
      )
    }
    // Webpack 4 compilation errors are strings
    return formatMessage(errorObjOrMessage)
  })
  if (formattedErrors.some(isLikelyASyntaxError)) {
    // If there are any syntax errors, show just them.
    formattedErrors = formattedErrors.filter(isLikelyASyntaxError)
  }
  return formattedErrors
}
Formats Webpack error messages into a more readable format.
@param {Array<string | WebpackErrorObj>} errors An array of Webpack error messages.
@returns {string[]} The formatted Webpack error messages.