File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/core/src/vite-bridge Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,13 @@ export function callViteServerAction<T>(name: string) {
21
21
const uniqueEventKey = nanoid ( )
22
22
return new Promise < T > ( ( resolve ) => {
23
23
const cb = ( e : T ) => {
24
- viteClient . off ( uniqueEventKey , cb )
24
+ if ( viteClient . off )
25
+ viteClient . off ( uniqueEventKey , cb )
26
+
27
+ else
28
+ // compatible with vite 4.x
29
+ viteClient . dispose ?.( cb )
30
+
25
31
resolve ( e )
26
32
}
27
33
viteClient . on ( uniqueEventKey , cb )
@@ -38,7 +44,12 @@ export function defineViteClientListener(name: string) {
38
44
const viteClient = getViteClientHotContext ( )
39
45
viteClient . on ( name , listener )
40
46
return ( ) => {
41
- viteClient . off ( name , listener )
47
+ if ( viteClient . off )
48
+ viteClient . off ( name , listener )
49
+
50
+ else
51
+ // compatible with vite 4.x
52
+ viteClient . dispose ?.( listener )
42
53
}
43
54
}
44
55
}
You can’t perform that action at this time.
0 commit comments