@@ -14,6 +14,7 @@ import {
14
14
IS_SSR_KEY ,
15
15
LOADER_ENTRIES_KEY ,
16
16
LOADER_SET_KEY ,
17
+ LOADER_SET_PROMISES_KEY ,
17
18
NAVIGATION_RESULTS_KEY ,
18
19
PENDING_LOCATION_KEY ,
19
20
} from './meta-extensions'
@@ -105,6 +106,7 @@ export function setupLoaderGuard({
105
106
const lazyLoadingPromises : Promise < unknown > [ ] = [ ]
106
107
107
108
for ( const record of to . matched ) {
109
+ console . log ( 'record' , record . meta [ LOADER_SET_KEY ] )
108
110
// we only need to do this once per record as these changes are preserved
109
111
// by the router
110
112
if ( ! record . meta [ LOADER_SET_KEY ] ) {
@@ -114,6 +116,7 @@ export function setupLoaderGuard({
114
116
// add all the loaders from the components to the set
115
117
for ( const componentName in record . components ) {
116
118
const component : unknown = record . components [ componentName ]
119
+ console . log ( 'component' , component , isAsyncModule ( component ) )
117
120
118
121
// we only add async modules because otherwise the component doesn't have any loaders and the user should add
119
122
// them with the `loaders` array
@@ -143,10 +146,17 @@ export function setupLoaderGuard({
143
146
}
144
147
}
145
148
}
149
+ console . log ( 'v' , viewModule )
146
150
} )
147
151
152
+ record . meta [ LOADER_SET_PROMISES_KEY ] ??= [ ]
153
+ record . meta [ LOADER_SET_PROMISES_KEY ] . push ( promise )
148
154
lazyLoadingPromises . push ( promise )
149
155
}
156
+ } else if ( record . meta [ LOADER_SET_PROMISES_KEY ] ) {
157
+ // When repeated navigation happen on the same route, loaders might still be
158
+ // resolved from async modules, so we need to wait for them to resolve.
159
+ lazyLoadingPromises . push ( ...record . meta [ LOADER_SET_PROMISES_KEY ] )
150
160
}
151
161
}
152
162
@@ -156,6 +166,7 @@ export function setupLoaderGuard({
156
166
// merge the whole set of loaders
157
167
for ( const loader of record . meta [ LOADER_SET_KEY ] ! ) {
158
168
to . meta [ LOADER_SET_KEY ] ! . add ( loader )
169
+ to . meta [ LOADER_SET_PROMISES_KEY ] = undefined
159
170
}
160
171
}
161
172
// we return nothing to remove the value to allow the navigation
0 commit comments