Skip to content
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

feat(nuxt): warn when components have a name conflict #27838

Merged
merged 6 commits into from
Jun 27, 2024

Conversation

GalacticHypernova
Copy link
Contributor

@GalacticHypernova GalacticHypernova commented Jun 26, 2024

🔗 Linked issue

closes #27800

📚 Description

This PR warns the user when a component is found with name conflicts that use the reserved Lazy prefix

Copy link

stackblitz bot commented Jun 26, 2024

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

@GalacticHypernova GalacticHypernova marked this pull request as ready for review June 26, 2024 09:34
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, if you update L96 as follows:

- const pascalName = pascalCase(componentNameSegments)
  const pascalName = pascalCase(componentNameSegments).replace(/^Lazy(?=[A-Z])/, '')

then this is what will be logged:

 WARN  Two component files resolving to the same name Bob:                                                     11:49:28 AM

 - /Users/daniel/code/nuxt/nuxt/playground/components/LazyBob.vue
 - /Users/daniel/code/nuxt/nuxt/playground/components/Bob.vue

That feels like a good approach, and it's an even more minimal change.

@GalacticHypernova
Copy link
Contributor Author

How about files that don't have a a non-lazy counterpart?

@danielroe
Copy link
Member

Hm - yes, it's probably worth over-warning, but it's most helpful when we can point to the component it would collide with.

either way, it shouldn't just be about the component file name but the resolved component name. So MyDirLazyComponent would be fine (~/components/my-dir/lazy-component.vue). And lazy-component.vue wouldn't be, even though it doesn't start with Lazy. And lazyn-component.vue would be fine.

@GalacticHypernova
Copy link
Contributor Author

Ah, I see. Yea, that is true, the warning will also need to be modified for it

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.

2 participants