2.4.0
2.4.1 - https://jsfiddle.net/bfpuee6e/
2.3.1 - https://jsfiddle.net/0ogdn5mu/
i expect the same behavior in 2.4.0 as in 2.3.1.
Vue router now resolves async component before global hooks have been resolved.
I'm not sure if we should go back to the previous behaviour because we can start getting the async comp while the beforeEnter is doing some computation or fetching and therefore provide a smoother experience.
I updated your repro to this: https://jsfiddle.net/qs161n6g/1 which is clearer in my opinion
because we can start getting the async comp while the beforeEnter is doing some computation or fetching and therefore provide a smoother experience.
I see but let me explain (based on my app auth-flow) why I would like to prevent this behavior... imagine this scenario:
I have these routes:
{
path: '/',
beforeEnter(to, from, next) {
next(isUserLoggedIn ? true : '/login')
},
component: () => import('./views/Panel')
children: [
{
path: '',
component: () => import('./views/Panel/Home')
}
]
},
{
path: '/login',
beforeEnter(to, from, next) {
next(isUserLoggedIn ? '/' : true)
},
component: () => import('./views/Login')
}
and some relevant parts on my app:
// don't resolve initial route due to pending authentication
router.beforeEach((to, from, next) => {);
// later in the code
AuthService.checkAuth().then((loggedIn) => {
// remove global hook
router.beforeHooks = []
// redirect user based on loggedIn status
})
How things worked before:
How things work now:
And this is a problem for me because, both chunks (Panel/Home) are very huge in my case ~350 kb, and and therefore I would prefer not to preload them before my authentication check is complete.
So my question now is - is there a way to bring back the old behavior or some kinda workaround for my case? I hope all is clear to you and appreciate the help :)
I see. There's probably something that can be done to improve the control of when to fetch the async view
Most helpful comment
I see. There's probably something that can be done to improve the control of when to fetch the async view