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

F12: No definition found for '<component-name>' #3490

Closed
4 tasks done
thany opened this issue Jul 28, 2022 · 1 comment
Closed
4 tasks done

F12: No definition found for '<component-name>' #3490

thany opened this issue Jul 28, 2022 · 1 comment
Labels

Comments

@thany
Copy link

thany commented Jul 28, 2022

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ
  • I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: Windows 10
  • Vetur version: v0.35.0
  • VS Code version: 1.69.2 (system setup)

Problem

Every attempt to F12 a component to jump to its definition, or even the file that is associated with it, fails:
image

It does the same thing for every component reference in every template. We don't use aliases, just all relative imports.

I do get some errors from the language server, but I'm not sure if they are applicable to this issue:

Vetur initialized
[INFO ] Loaded bundled typescript@4.4.4.
[INFO ] Loaded bundled prettier.
[INFO ] Loaded bundled @starptech/prettyhtml.
[INFO ] Loaded bundled prettier-eslint.
[INFO ] Loaded bundled prettier-tslint.
[INFO ] Loaded bundled stylus-supremacy.
[INFO ] Loaded bundled @prettier/plugin-pug.
[Error - 17:34:38] Request textDocument/semanticTokens/range failed.
  Message: Request textDocument/semanticTokens/range failed with message: Cannot read properties of undefined (reading 'flags')
  Code: -32603 
[Error - 17:34:39] Request textDocument/semanticTokens/full failed.
  Message: Request textDocument/semanticTokens/full failed with message: Cannot read properties of undefined (reading 'flags')
  Code: -32603 
[Error - 17:34:39] Request textDocument/semanticTokens/range failed.
  Message: Request textDocument/semanticTokens/range failed with message: Cannot read properties of undefined (reading 'flags')
  Code: -32603 
[Error - 17:36:19] Request textDocument/semanticTokens/range failed.
  Message: Request textDocument/semanticTokens/range failed with message: Cannot read properties of undefined (reading 'flags')
  Code: -32603 
[Error - 17:38:38] Request textDocument/semanticTokens/range failed.
  Message: Request textDocument/semanticTokens/range failed with message: Cannot read properties of undefined (reading 'flags')
  Code: -32603 

Every now and then - I don't know exactly when, or I would happily tell you - that last error message repeats itself.

Reproducible Case

I think the main thing is that we use require.context to load all component in a project at once, and Vue.use them in bulk. Perhaps Vetur just simply doesn't see this piece of code, or doesn't know how to deal with it.

require.context is a specific webpack feature, so it's possible that we're doing things completely wrong. In that case, I feel lucky not to have been the bloke to set up our project, but I do have to make sense of it.

I can make a repro repo, but it'll take time (which I don't have enough of). If you really think it will actually lead to a solution, rather than "oh sorry, we can't support that" and wasting my time (no offense), then I'll be happy to create you something. Otherwise it might be better to point me to some advise on how to better import 200-or-so components. Because I'm totally new with Vue and I have no idea what Vue (and indeed Vetur) expects component imports to look like, or where they should live.

@yoyo930021
Copy link
Member

The require.context is dynamic. It isn't parse and analysis well when compiler time.
You can use Global components feature in this case.
https://vuejs.github.io/vetur/guide/global-components.html#example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants