Skip to content
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

More verbose error messaging for Vue 2 style dynamic imports - Invalid VNode type: undefined #2497

Open
fimion opened this issue Oct 27, 2020 · 4 comments
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ✨ feature request New feature or request

Comments

@fimion
Copy link

fimion commented Oct 27, 2020

What problem does this feature solve?

I know that there is work being done to create friendlier and more helpful errors for migrating code bases. I've recently done a migration from 2 to 3 on a small demo I work on, and I found the messaging when erroring on old style dynamic imports to be extremely unhelpful.

The previous style dynamic imports looked like this:

const MyComponent = () => import('./MyComponent.vue');

However, when migrating, the error received for this type of import is a bit lacking:

[Vue warn]: Invalid VNode type: undefined (undefined) 
  at <MyComponent>

So I am aware of what is causing the error, but I have no idea how to fix it or that I would need to import defineAsyncComponent.

What does the proposed API look like?

in the error message handling for this, would it be possible to check if the thing that errored is the Vue 2 style import and link to the appropriate migration docs?

[Vue warn]: Invalid VNode type: undefined (undefined) 
  at <MyComponent>
[Vue warn]: It looks like you are using a Vue 2.x style dynamic import. You'll need to use defineAsyncComponent to do this now.
[Vue warn]: https://v3.vuejs.org/guide/migration/async-components.html

or something similar?

@edison1105
Copy link
Member

We can also do this in Vetur

@fimion
Copy link
Author

fimion commented Nov 1, 2020

so based on my quick search, it looks like this error is happening here ish (as of 11/01/2020):
https://github.com/vuejs/vue-next/blob/fff62e2ee8accf31bb5ac5abdb4c0636216cfd0e/packages/runtime-core/src/renderer.ts#L549

I can take a crack at this if no one objects?

@posva
Copy link
Member

posva commented Nov 18, 2020

@fimion A better warning should indeed help migration! Feel free to give it a try

@posva posva added the ✨ feature request New feature or request label Nov 18, 2020
@panstromek
Copy link

I bumped into this, too. Some nicer error would be appreciated, because it was just one of many breakages I was dealing with during migration, so it took some time to find out what is the cause. Currently there's no indication of what to look for when you see this error.

Note that if the element is inside a transition, you get different error: Component inside <Transition> renders non-element root node that cannot be animated, which is even more misleading, because Transition had breaking changes, too. This led me down the rabbit hole of debugging the transition element interaction, even though the problem was just the async component.

@haoqunjiang haoqunjiang added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ✨ feature request New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants