vuedx / languagetools

A collection of tools for better IDE experience.

Home Page:https://vuedx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Define components that don't need importing

gregveres opened this issue · comments

Is your feature request related to a problem? Please describe.
I am using Vuetify, which has a feature for pre-loading components. I have some components that are located on the majority of the pages, so I am using the pre-loading feature. One such component is called SBtn.

The problem happens when I have VueDX enabled and I use SBtn in the markup, VueDX automatically adds SBtn to the list of imports and to the list of components used by the component I am building.

I would like a way to tell VueDX that SBtn is one of the "native" components that doesn't need to be imported.

Describe the solution you'd like
I would like to configure a list of native components that VueDX will not automatically load into the component being constructed. I assume there is a config file somewhere that this config setting could be added to.

Describe alternatives you've considered
The alternative is to do what I am doing today. Every time I add an SBtn to a new component, VueDX adds the import and component entry and then I have to go remove it before I commit the file. This is error prone and time consuming.

Another alternative I have thought of is removing VueDX altogether to avoid this hassle, but the auto loading of components when it is a component that isn't pre-loaded is very, very useful and I want to keep taking advantage of that. So, right now I live with the pain for these pre-loaded components. However, as you can imagine, this components are pre-loaded because they are used a lot.

There is an undocumented config option. You can create vueconfig.json and add global components to it. For reference, you can see type definitions of config object: https://github.com/znck/vue-developer-experience/blob/main/packages/projectconfig/src/index.ts. The VueDX extension defines json schema so you should get completions in this file. If not using VS Code, you can use schema from https://github.com/znck/vue-developer-experience/blob/main/packages/projectconfig/schema.json

Well, don't I look stupid now.

It turns out the feature I was complaining about isn't from VueDX, it is from Vetur. It is Vetur that allows me to type a component name and hit tab to load it and add it to the imports. I thought that was VueDX.

I do see what you are saying though about defining information about the globally imported components. I will follow up with that tip. Thanks. Now I am off to Vetur to ask them about this feature request.