Unverified Commit 70d64382 authored by Jan Kaifer's avatar Jan Kaifer Committed by GitHub

Improve the readability of full page refresh error in dev mode (#46634)

Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 533748d3
...@@ -389,7 +389,24 @@ export default class HotReloader { ...@@ -389,7 +389,24 @@ export default class HotReloader {
stackTrace stackTrace
)?.[1] )?.[1]
if (file) { if (file) {
fileMessage = ` when ${file} changed` // `file` is filepath in `pages/` but it can be weird long webpack url in `app/`.
// If it's a webpack loader URL, it will start with '(app-client)/./'
if (file.startsWith('(app-client)/./')) {
const fileUrl = new URL(file, 'file://')
const cwd = process.cwd()
const modules = fileUrl.searchParams
.getAll('modules')
.map((filepath) => filepath.slice(cwd.length + 1))
.filter(
(filepath) => !filepath.startsWith('node_modules')
)
if (modules.length > 0) {
fileMessage = ` when ${modules.join(', ')} changed`
}
} else {
fileMessage = ` when ${file} changed`
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment