JetBrains / web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
Apache License 2.0
285 stars 25 forks source link

Support for locally imported components #59

Closed kawazoe closed 1 year ago

kawazoe commented 2 years ago

In VueJs, component dependencies can be imported locally in each file. They do not have to be registered globally, even for libraries. Since components are exported using the default export, they also have no name. Instead, their tag will match the name of the variable that declared the component. Eg:

<template>
  <my-fancy-component></my-fancy-component>
  <another-name></another-name>
  <foo-bar></foo-bar>
</template>
<script setup>
import MyFancyComponent from '@/components/MyFancyComponent';
import AnotherName from '@/components/MyFancyComponent';
const FooBar = MyFancyComponent;
</script>

In this case, all three names are valid since they reference the same default export.

Thus, it should be possible to declare a "vue-component" contribution not by name or type, but by module/file only. Any tag matching a variable affected from the default export should match the web-type. The import shouldn't appear as "unused" (like right now), even if the web-type is declared with highest priority.

piotrtomiak commented 1 year ago

@kawazoe This issue should be fixed in the latest 2022.3. You still need to provide the component name in Web Types to have some default name for code completion, however the two sources: Web Types and component source will be properly merged if Web Types contain correct source property, which points to the imported component definition.