unplugin / unplugin-vue-components

📲 On-demand components auto importing for Vue
https://www.npmjs.com/package/unplugin-vue-components
MIT License
3.66k stars 341 forks source link

Ideas and thoughts on populating components.d.ts from scratch #718

Open Vanilagy opened 7 months ago

Vanilagy commented 7 months ago

Because it qualifies as "derived state", we do not check in our components.d.ts file into source control. For our typechecking CI actions, it is crucial that all of the components be declared in this file so that all errors can be caught. However, since the file only gets extended / populated when a given component gets compiled by Vite, I am not sure how to properly generate this file from scratch.

One approach that does work and that does hit all components is simply:

vite build

But this is quite slow and costly, since it runs an entire build. I'd rather have something that walks the depencency tree like Vite does, and transform Vue components using this plugin, but that's all it does and it also doesn't emit any built files.

Has this been attempted before, or does any of you have suggestions how I might approach something like this? Maybe a build piped to /dev/null? Or is there something more direct this library offers?