nuxtlabs / nuxt-component-meta

Gather Nuxt components metadata on build time and make them available on production.
73 stars 8 forks source link

feat: add `extendComponentMeta` #73

Closed romhml closed 3 weeks ago

romhml commented 1 month ago

This is a quick PoC to discuss about the introduction of a extendComponentMeta function to allow users to pass arbitrary objects into component meta data like so:

<script setup>
extendComponentMeta({ hello: 'world' })
</script>

This would allow library authors to pass additional component data to implement devtools more easily.

We might consider implementing a vite plugin to remove the function from the bundle after we parsed it. It might also make more sense to include it in vue-component-meta since this is where most of the parsing is done.

farnabaz commented 3 weeks ago

Thank you @romhml I'm merging this to test on the package and we can iterate on it in next releases

romhml commented 3 weeks ago

I ended up implementing a slightly better version than this here if you want to have a look: https://github.com/nuxt/ui/pull/2196/files#diff-4795a876424cc5bbc19726d11b6ff10eb6002253ad1d74dea1b1f7b47822e196R37