Skip to content

Commit b59a78c

Browse files
committed
chore: update hmr log
1 parent 0538ebe commit b59a78c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

packages/vite/src/node/build.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import type { RollupCommonJSOptions } from 'dep-types/commonjs'
2929
import type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
3030
import type { EsbuildTarget } from 'types/internal/esbuildOptions'
3131
import type { ChunkMetadata } from 'types/metadata'
32+
import type { Update } from 'types/hmrPayload'
3233
import { withTrailingSlash } from '../shared/utils'
3334
import {
3435
DEFAULT_ASSETS_INLINE_LIMIT,
@@ -924,6 +925,7 @@ async function buildEnvironment(
924925

925926
if (server) {
926927
server.watcher.on('change', async (file) => {
928+
logger.info(`${colors.green(`${path.relative(root, file)} changed.`)}`)
927929
const startTime = Date.now()
928930
const hmrOutput = (await bundle!.generateHmrPatch([file]))!
929931
// @ts-expect-error Need to upgrade rolldown
@@ -941,23 +943,29 @@ async function buildEnvironment(
941943
if (hmrOutput.patch) {
942944
const url = `${Date.now()}.js`
943945
server.memoryFiles[url] = hmrOutput.patch
946+
const updates = hmrOutput.hmrBoundaries.map((boundary) => {
947+
return {
948+
type: 'js-update',
949+
url,
950+
path: boundary.boundary,
951+
acceptedPath: boundary.acceptedVia,
952+
timestamp: 0,
953+
}
954+
}) as Update[]
944955
server.ws.send({
945956
type: 'update',
946-
updates: hmrOutput.hmrBoundaries.map((boundary) => {
947-
return {
948-
type: 'js-update',
949-
url,
950-
path: boundary.boundary,
951-
acceptedPath: boundary.acceptedVia,
952-
timestamp: 0,
953-
}
954-
}),
957+
updates,
955958
})
956959
logger.info(
957-
`${colors.green(`✓ Found ${path.relative(root, file)} changed, rebuilt in ${displayTime(Date.now() - startTime)}`)}`,
960+
colors.green(`hmr update `) +
961+
colors.dim([...new Set(updates.map((u) => u.path))].join(', ')),
962+
{ clear: true, timestamp: true },
958963
)
959964

960965
await build()
966+
logger.info(
967+
`${colors.green(`✓ rebuilt in ${displayTime(Date.now() - startTime)}`)}`,
968+
)
961969
}
962970
})
963971
}

0 commit comments

Comments
 (0)