@@ -29,6 +29,7 @@ import type { RollupCommonJSOptions } from 'dep-types/commonjs'
2929import type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
3030import type { EsbuildTarget } from 'types/internal/esbuildOptions'
3131import type { ChunkMetadata } from 'types/metadata'
32+ import type { Update } from 'types/hmrPayload'
3233import { withTrailingSlash } from '../shared/utils'
3334import {
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