Skip to content

feat(nuxt): allow generating metadata for nuxt components #26204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

resolves #15015

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This adds a new option: components.generateMetadata which writes ~/.nuxt/components.json which could be consumed by other integrations to get information about the auto-imported components in your app.

The original use case of this (eslint) will likely be implemented differently so it may be worth reconsidering this and/or closing the PR. What do you think @antfu?

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Sorry, something went wrong.

Copy link

stackblitz bot commented Mar 11, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@antfu
Copy link
Member

antfu commented Mar 13, 2024

If we end up recommending the eslint config generation approach (nuxt/eslint#332), where the module can directly grab the necessary data from module hooks, I guess we don't need core to support that - unless there would be other cases to consume those data

@pi0
Copy link
Member

pi0 commented Mar 13, 2024 β€’

I think it makes sense only if we can make it opt-in and expandable for component extracted meta (similar to nuxt-component-meta).

The advantage of being in core is that there is a unified protocol (+ caching chance to avoid preparing same SFC multiple times) to augment and access component data and it is probably valuable.

@danielroe
Copy link
Member Author

Yes, this is opt-in - it has be enabled with components.generateMeta.

Are you thinking we could support an additional field (meta?) on each component that could be populated?

@pi0
Copy link
Member

pi0 commented Mar 13, 2024

additional meta object to be expandable with hooks sound a nice idea. Also for sure yes being opt-in makes sense.

Copy link
Contributor

nuxt-studio bot commented Mar 13, 2024

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview 0a8d758

@danielroe danielroe merged commit a9effe9 into main Mar 13, 2024
35 of 36 checks passed
@danielroe danielroe deleted the feat/components-meta branch March 13, 2024 22:57
@github-actions github-actions bot mentioned this pull request Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Retrieve auto-imported component / function names
3 participants