Skip to content

Commit

Permalink
better error message when component is a promise (fix vuejs#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke committed Apr 16, 2020
1 parent 11e779a commit 43db967
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/create-route-map.js
Expand Up @@ -37,7 +37,7 @@ export function createRouteMap (
if (process.env.NODE_ENV === 'development') {
// warn if routes do not include leading slashes
const found = pathList
// check for missing leading slash
// check for missing leading slash
.filter(path => path && path.charAt(0) !== '*' && path.charAt(0) !== '/')

if (found.length > 0) {
Expand Down Expand Up @@ -70,6 +70,12 @@ function addRouteRecord (
path || name
)} cannot be a ` + `string id. Use an actual component instead.`
)
assert(
route.component.toString() !== '[object Promise]',
`route config "component" for path: ${String(
path || name
)} cannot be a promise. Use a function that returns a promise instead (e.g. \`() => import ('./components/About.vue')\`)`
)
}

const pathToRegexpOptions: PathToRegexpOptions =
Expand Down Expand Up @@ -112,12 +118,12 @@ function addRouteRecord (
warn(
false,
`Named Route '${route.name}' has a default child route. ` +
`When navigating to this named route (:to="{name: '${
route.name
}'"), ` +
`the default child route will not be rendered. Remove the name from ` +
`this route and use the name of the default child route for named ` +
`links instead.`
`When navigating to this named route (:to="{name: '${
route.name
}'"), ` +
`the default child route will not be rendered. Remove the name from ` +
`this route and use the name of the default child route for named ` +
`links instead.`
)
}
}
Expand Down Expand Up @@ -169,7 +175,7 @@ function addRouteRecord (
warn(
false,
`Duplicate named routes definition: ` +
`{ name: "${name}", path: "${record.path}" }`
`{ name: "${name}", path: "${record.path}" }`
)
}
}
Expand Down

0 comments on commit 43db967

Please sign in to comment.