@@ -103,24 +103,25 @@ export async function handleHotUpdate(
103
103
104
104
// custom blocks update causes a reload
105
105
// because the custom block contents is changed and it may be used in JS.
106
- for ( let i = 0 ; i < nextCustoms . length ; i ++ ) {
107
- const prev = prevCustoms [ i ]
108
- const next = nextCustoms [ i ]
109
- if ( ! prev || ! isEqualBlock ( prev , next ) ) {
110
- const mod = modules . find ( ( m ) =>
111
- m . url . includes ( `type=${ prev . type } &index=${ i } ` )
112
- )
113
- if ( mod ) {
114
- affectedModules . add ( mod )
115
- } else {
116
- affectedModules . add ( mainModule )
106
+ if ( prevCustoms . length !== nextCustoms . length ) {
107
+ // block rmeoved/added, force reload
108
+ affectedModules . add ( mainModule )
109
+ } else {
110
+ for ( let i = 0 ; i < nextCustoms . length ; i ++ ) {
111
+ const prev = prevCustoms [ i ]
112
+ const next = nextCustoms [ i ]
113
+ if ( ! prev || ! isEqualBlock ( prev , next ) ) {
114
+ const mod = modules . find ( ( m ) =>
115
+ m . url . includes ( `type=${ prev . type } &index=${ i } ` )
116
+ )
117
+ if ( mod ) {
118
+ affectedModules . add ( mod )
119
+ } else {
120
+ affectedModules . add ( mainModule )
121
+ }
117
122
}
118
123
}
119
124
}
120
- if ( prevCustoms . length > nextCustoms . length ) {
121
- // block rmeoved, force reload
122
- affectedModules . add ( mainModule )
123
- }
124
125
125
126
let updateType = [ ]
126
127
if ( needRerender ) {
0 commit comments