Turbopack: improve error display (#58734)

### What?

* include path and title in errors
* don't block the page for errors in node_modules

### Why?

### How?

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Tobias Koppers 2023-11-21 19:57:41 +01:00 committed by GitHub
parent 642ad12c29
commit 5ab289caae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -305,10 +305,12 @@ async function startWatcher(opts: SetupOpts) {
const { start } = source.range const { start } = source.range
message = `${issue.severity} - ${formattedFilePath}:${ message = `${issue.severity} - ${formattedFilePath}:${
start.line + 1 start.line + 1
}:${start.column}` }:${start.column} ${formattedTitle}`
} else { } else {
message = `${issue.severity} - ${formattedFilePath} ${formattedTitle}` message = `${issue.severity} - ${formattedFilePath} ${formattedTitle}`
} }
} else if (formattedFilePath) {
message = `${formattedFilePath} ${formattedTitle}`
} else { } else {
message = `${formattedTitle}` message = `${formattedTitle}`
} }
@ -368,6 +370,9 @@ async function startWatcher(opts: SetupOpts) {
console.error(`${displayName} ${formatted}\n\n`) console.error(`${displayName} ${formatted}\n\n`)
} }
newSet.set(key, issue) newSet.set(key, issue)
// We show errors in node_modules to the console, but don't throw for them
if (/(^|\/)node_modules(\/|$)/.test(issue.filePath)) continue
relevantIssues.add(formatted) relevantIssues.add(formatted)
} }