mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
perf: await routeData promises in parallel (#5027)
This commit is contained in:
parent
176641f6cb
commit
0826d7e5fd
@ -106,6 +106,9 @@ export function resolveRouteComponents(route) {
|
||||
}
|
||||
|
||||
export async function getRouteData(route) {
|
||||
if (!route) {
|
||||
return
|
||||
}
|
||||
// Make sure the components are resolved (code-splitting)
|
||||
await resolveRouteComponents(route)
|
||||
// Send back a copy of route with meta based on Component definition
|
||||
@ -188,19 +191,27 @@ export async function setContext(app, context) {
|
||||
app.context.nuxtState = window.<%= globals.context %>
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamic keys
|
||||
const [currentRouteData, fromRouteData] = await Promise.all([
|
||||
getRouteData(context.route),
|
||||
getRouteData(context.from)
|
||||
])
|
||||
|
||||
if (context.route) {
|
||||
app.context.route = currentRouteData
|
||||
}
|
||||
|
||||
if (context.from) {
|
||||
app.context.from = fromRouteData
|
||||
}
|
||||
|
||||
app.context.next = context.next
|
||||
app.context._redirected = false
|
||||
app.context._errored = false
|
||||
app.context.isHMR = !!context.isHMR
|
||||
if (context.route) {
|
||||
app.context.route = await getRouteData(context.route)
|
||||
}
|
||||
app.context.params = app.context.route.params || {}
|
||||
app.context.query = app.context.route.query || {}
|
||||
if (context.from) {
|
||||
app.context.from = await getRouteData(context.from)
|
||||
}
|
||||
}
|
||||
|
||||
export function middlewareSeries(promises, appContext) {
|
||||
|
Loading…
Reference in New Issue
Block a user