You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/navigationGuards.ts
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,16 @@ export function extractComponentsGuards(
166
166
167
167
for(constrecordofmatched){
168
168
for(constnameinrecord.components){
169
-
constrawComponent=record.components[name]
169
+
letrawComponent=record.components[name]
170
+
// warn if user wrote import('/component.vue') instead of () => import('./component.vue')
171
+
if(__DEV__&&'then'inrawComponent){
172
+
warn(
173
+
`Component "${name}" in record with path "${record.path}" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')"? This will break in production if not fixed.`
174
+
)
175
+
letpromise=rawComponent
176
+
rawComponent=()=>promise
177
+
}
178
+
170
179
if(isRouteComponent(rawComponent)){
171
180
// __vccOpts is added by vue-class-component and contain the regular options
172
181
letoptions: ComponentOptions=
@@ -182,7 +191,7 @@ export function extractComponentsGuards(
182
191
183
192
if(__DEV__&&!('catch'incomponentPromise)){
184
193
warn(
185
-
`Component "${name}" at record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`
194
+
`Component "${name}" in record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`
0 commit comments