-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize the RouterManager.addRoutes
#3454
Comments
Additional comment for point 2: Is it necessary to create routes for all stores? Considering it's not possible to navigate directly between stores. Instead, the app gets reloaded, and all the routes recreated. So only the current store routes need to be added. Right? The exception is SSR for SEO, but that can be handled separately. This also seems like a big change though and could possibly affect some customizations. In the end, I thought this simple fix would be best for 1.10.1 and maybe a bigger update can be planned for 1.11. What do you think? |
@pkarw
Do you think the default store routes are needed when on another store? |
I think they're not - probably - hard for me to find the exceptions ... |
@grimasod it would be coll if by chance of this PR we'll add a Related to: https://vuestorefront.slack.com/archives/C8JMCHQ6S/p1567757048024000 |
@pkarw Sure :) |
by ddefault theme should have the highest priority I belive |
@grimasod I just wanted to check the status as we're planning to release 1.11rc1 on 19th of September |
@pkarw I've started on part 1, but it's not so simple - for example, Dynamic Route processing expects the routes to be already registered. I have limited time to work on this, but I hope to make some progress by the end of this week |
@pkarw I've made a PR for part 1, but it's not finished. There are issues with dynamic routes |
What is the motivation for adding / enhancing this feature?
Related to: #3443
The goal: to reduce the number of times the router beforeEach hooks are run
@grimasod to optimize this route registration, going down to one and only
router.addRoutes
call I belive we need just to implement aRouterManager.routeQueue[]
whereRouteManager.addRoutes
Has new optional argumentuseRouteQueue=False
calls are adding the routes and then the methodRouteManager.registerRoutes
orRouteManager.flushRouteQueue
which is doing the real registration; this method should be called after all the theme and module routes were registered. We need to change all the core calls toRouter.addRoutes
to set theuseRouteQueue=true
. The default value would be `false for backward compatibility + the calls made after the queue was flushed@grimasod you’re probably right about the multistore route registration but probably: a) just for CSR (as you said for SEO and language switching features we need to have the server side links for other lang versions); b) based on the
storeCode
- we always know the current store code because it’s being guessed on URL/Header/Host before modules were registered. So knowing thecurrentStoreView
we can register only the right set of routes (if they’re different from the default routes) - so for default there would be single route registration, for any other lang version probably 2 calls but not 3,4,10 ...The text was updated successfully, but these errors were encountered: