This repository was archived by the owner on Apr 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/vite/src/runtime Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { performance } from 'node:perf_hooks'
1
2
import { ViteNodeRunner } from 'vite-node/client'
2
3
import { $fetch } from 'ohmyfetch'
4
+ import consola from 'consola'
3
5
import { getViteNodeOptions } from './vite-node-shared.mjs'
4
6
5
7
const viteNodeOptions = getViteNodeOptions ( )
@@ -25,12 +27,21 @@ export default async (ssrContext) => {
25
27
const invalidates = await $fetch ( '/invalidates' , {
26
28
baseURL : viteNodeOptions . baseURL
27
29
} )
30
+ const updates = new Set ( )
28
31
for ( const key of invalidates ) {
29
- runner . moduleCache . delete ( key )
32
+ if ( runner . moduleCache . delete ( key ) ) {
33
+ updates . add ( key )
34
+ }
30
35
}
31
36
32
37
// Execute SSR bundle on demand
38
+ const start = performance . now ( )
33
39
render = render || ( await runner . executeFile ( viteNodeOptions . entryPath ) ) . default
40
+ if ( updates . size ) {
41
+ const time = Math . round ( ( performance . now ( ) - start ) * 1000 ) / 1000
42
+ consola . success ( `Vite server hmr ${ updates . size } files` , time ? `in ${ time } ms` : '' )
43
+ }
44
+
34
45
const result = await render ( ssrContext )
35
46
return result
36
47
}
You can’t perform that action at this time.
0 commit comments