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

fix(nuxt): ensure all dir parts are present in component name #20779

Merged
merged 18 commits into from May 15, 2023

Conversation

baiwusanyu-c
Copy link
Contributor

@baiwusanyu-c baiwusanyu-c commented May 11, 2023

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 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

close: #20613

📝 Checklist

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

@baiwusanyu-c baiwusanyu-c changed the title fix(nuxt): fix scan components error fix(nuxt): fix scan components error( #20613 ) May 11, 2023
@baiwusanyu-c baiwusanyu-c changed the title fix(nuxt): fix scan components error( #20613 ) fix(nuxt): fix scan components error(#20613) May 11, 2023
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.

This looks great - thank you! ❤️

I've extracted your code into a separate helper function and wrote some unit tests to describe the behaviour I think we are expecting, and which isn't entirely working yet... What do you think?

@baiwusanyu-c
Copy link
Contributor Author

@danielroe Thank you very much for your help. I think I misunderstood his rules and logic. Now I think we need to find the judgment condition and complete the prefixPart.

@baiwusanyu-c
Copy link
Contributor Author

baiwusanyu-c commented May 15, 2023

I added some tests based on the bug( ['Item', ['Item', 'Holder', 'Item'], 'ItemHolderItem']) and the test case you provided, and ran the original code and the original commit (3d6af90) separately, and found that they didn't pass the tests.

fileName prefixParts expected original code 3d6af90
WithClientOnlySetup ['Client'] ClientWithClientOnlySetup ClientWithClientOnlySetup✅ ClientWithClientOnlySetup ✅
ItemHolderItem ['Item', 'Holder', 'Item'] ItemHolderItem ItemHolderItem✅ ItemHolderItemHolderItem❌
Item ['Item'] Item Item✅ Item ✅
Item ['Item','Item'] Item Item✅ ItemItem❌
ItemTest ['Item', 'Test'] ItemTest ItemTest✅ ItemTest ✅
ThingItemTest ['Item', 'Thing'] ThingItemTest ThingItemTest✅ ThingItemTest✅
Item ['Thing', 'Item'] ThingItem ThingItem✅ ThingItem✅
Item ['Item', 'Holder', 'Item'] ItemHolderItem Item❌ ItemHolderItem✅
ItemHolder ['Item', 'Holder', 'Item'] ItemHolderItemHolder ItemHolder❌ ItemHolderItemHolder✅
ThingItemTest ['Item', 'Thing', 'Foo'] ItemThingFooThingItemTest ItemThingItemTest❌ ItemThingItemTest❌
ItemIn ['Item', 'Holder', 'Item', 'In'] ItemHolderItemIn ItemIn✅ ItemHolderItemIn✅
Item ['Item', 'Holder', 'Test'] ItemHolderTestItem Item❌ Item❌
ItemHolderItem ['Item', 'Holder', 'Item', 'Holder'] ItemHolderItemHolderItem ItemHolderItem❌ ItemHolderItemHolderItem✅

Especially ['Item', ['Item', 'Holder', 'Test'], 'ItemHolderTestItem'] and ['ThingItemTest', ['Item', 'Thing', 'Foo'], 'ItemThingFooThingItemTest ']

So I used startsWith to modify the matching implementation, but it still failed the test of ['Item', ['Item', 'Item'], 'Item'], so I added some judgments(08ad5de)) to ensure It passes the test and behaves the same as the original code

@danielroe danielroe requested a review from pi0 May 15, 2023 10:15
@danielroe danielroe changed the title fix(nuxt): fix scan components error(#20613) fix(nuxt): ensure all dir parts are present in component name May 15, 2023
@danielroe danielroe merged commit ce84c9b into nuxt:main May 15, 2023
18 checks passed
@baiwusanyu-c baiwusanyu-c deleted the bwsy/fix/scan-components branch May 15, 2023 12:35
This was referenced May 15, 2023
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.

Component name resolution is broken in some cases
2 participants