function vfileMessageToEsbuild(state, message) {
  /** @type {Location} */
  const location = {
    column: 0,
    file: state.path,
    length: 0,
    line: 0,
    lineText: '',
    namespace: 'file',
    suggestion: ''
  }

  const place = message.place
  const start = place ? ('start' in place ? place.start : place) : undefined
  if (start) {
    location.column = start.column - 1
    location.line = start.line
    location.length = 1

    const end = place && 'end' in place ? place.end : undefined
    if (end) {
      if (start.offset !== undefined && end.offset !== undefined) {
        location.length = end.offset - start.offset
      } else if (end.line === start.line) {
        location.length = end.column - start.column
      }
    }

    if (start.offset !== undefined) {
      eol.lastIndex = start.offset
      const match = eol.exec(state.doc)
      const lineStart = start.offset - (start.column - 1)
      const lineEnd = match ? match.index : state.doc.length
      location.lineText = state.doc.slice(lineStart, lineEnd)
      location.length = Math.min(location.length, lineEnd - (start.offset || 0))
    }

    const maxLength = state.doc.length - (start.offset || 0)
    location.length = Math.min(location.length, maxLength)
  }

  let text = message.reason
  if (message.cause) {
    text = `${text}:\n  ${message.cause}`
  }

  return {
    detail: message,
    id: '',
    location,
    notes: [],
    pluginName: state.name,
    text
  }
}
@param {Readonly<State>} state
  Info passed around.
@param {Readonly<VFileMessage>} message
  VFile message or error.
@returns {Message}
  ESBuild message.