Skip to content

Commit

Permalink
fix(app-vite): preFetch may error out with newer vue-router #14172
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Aug 15, 2022
1 parent c3e12bd commit 32b9147
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app-vite/templates/entry/client-prefetch.js
Expand Up @@ -33,7 +33,11 @@ function getMatchedComponents (to, router) {

if (!route) { return [] }

return Array.prototype.concat.apply([], route.matched.map(m => {
const matched = route.matched.filter(m => m.components !== void 0)

if (matched.length === 0) { return [] }

return Array.prototype.concat.apply([], matched.map(m => {
return Object.keys(m.components).map(key => {
const comp = m.components[key]
return {
Expand Down
1 change: 1 addition & 0 deletions app-vite/templates/entry/server-entry.js
Expand Up @@ -138,6 +138,7 @@ export default ssrContext => {
// wait until router has resolved possible async hooks
router.isReady().then(() => {
let matchedComponents = router.currentRoute.value.matched
.filter(record => record.components !== void 0)
.flatMap(record => Object.values(record.components))

// no matched routes
Expand Down

0 comments on commit 32b9147

Please sign in to comment.