nuxtlabs / nuxt-component-meta

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

feat!: use vue-component-meta #34

Closed stafyniaksacha closed 1 year ago

stafyniaksacha commented 1 year ago

⚠️ This introduces breaking change in schemas (more details here)

This is the first implementation of vue-component-meta to extract props/events/slots/exposed using typescript vue language service parser from volar - replaces #23

It can force usage of typescript in javascript components (thanks that vue3 is written in typescript) so detection work, but it needs a tsconfig.json in the root of the project. (can be achieved within vue-component-meta)

#nuxt-component-meta virtual module is exposed, so we can use meta inside the project without using a $fetch (useful to create components documentation) - replaces #32

farnabaz commented 1 year ago

Generally LGTM 👍 , but there are some issues we should deal with:

Also, I would love to have @kevinmarrec review, about the schema and possible breaking changes for the editor.

stafyniaksacha commented 1 year ago
  • Default values of props are missing
  • In normal components(TestComponent), all props are marked as required

Should be resolved with https://github.com/johnsoncodehk/volar/pull/1665

Tahul commented 1 year ago

@kevinmarrec @farnabaz ; could we state on this PR quickly?

I would love to see this happen to iterate on Studio Elements components documentation we're building.

farnabaz commented 1 year ago

Everything looks good to me, The only remaining thing is the tests. @stafyniaksacha Do you mind updating tests?

stafyniaksacha commented 1 year ago

Everything looks good to me, The only remaining thing is the tests. @stafyniaksacha Do you mind updating tests?

Yep, I'm on it.

I've found that the library is not able to load components from node_modules (this affects autoloaded components library) I don't know if this is a required feature for now, but I think this will be fixed upstream on vue-component-meta

Tahul commented 1 year ago

Hey @stafyniaksacha ; noticed some changes 😄

Is this PR ready for review again?

I'm willing to have this ASAP for usage in multiple Nuxt packages, that work is amazing!

stafyniaksacha commented 1 year ago

Hey @Tahul ! Yes pretty much ready, waiting on next release of vue-component-meta, so we can get rid of tsconfig.json that is required now. https://github.com/johnsoncodehk/volar/blob/master/packages/vue-component-meta/tests/index.spec.ts#L684-L693

This is why the tests are failing, we can not create one in tests/fixtures/base because @nuxt/test-utils will create a random folder under .nuxt

{
  "extends": "./.nuxt/random-xxx/tsconfig.json"
}

https://github.com/nuxt/framework/blob/main/packages/test-utils/src/nuxt.ts#L42

stafyniaksacha commented 1 year ago

Hey @Tahul @farnabaz That's should be ready ;)