Unverified Commit f171cf41 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: add HMR update message (#57476)

add NEXT_HMR_TIMING env var to show hmr timings in turbopack

Closes WEB-1880
parent 7c3511cd
......@@ -500,6 +500,7 @@ async function startWatcher(opts: SetupOpts) {
hmrBuilding = true
}
hmrPayloads.set(`${key}:${id}`, payload)
hmrEventHappend = true
sendHmrDebounce()
}
......@@ -512,6 +513,7 @@ async function startWatcher(opts: SetupOpts) {
hmrBuilding = true
}
turbopackUpdates.push(payload)
hmrEventHappend = true
sendHmrDebounce()
}
......@@ -1160,6 +1162,21 @@ async function startWatcher(opts: SetupOpts) {
await writeFontManifest()
await writeLoadableManifest()
let hmrEventHappend = false
if (process.env.NEXT_HMR_TIMING) {
;(async (proj: Project) => {
for await (const updateInfo of proj.updateInfoSubscribe()) {
if (hmrEventHappend) {
const time = updateInfo.duration
const timeMessage =
time > 2000 ? `${Math.round(time / 100) / 10}s` : `${time}ms`
Log.event(`Compiled in ${timeMessage}`)
hmrEventHappend = false
}
}
})(project)
}
const overlayMiddleware = getOverlayMiddleware(project)
const turbopackHotReloader: NextJsHotReloaderInterface = {
turbopackProject: project,
......
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