Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): add warning in dev mode if layouts/pages do not have a single root node #5469

Merged
merged 12 commits into from
Aug 23, 2022

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Jun 15, 2022

πŸ”— Linked issue

resolves nuxt/nuxt#13828, resolves nuxt/nuxt#14535

❓ 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This is a persistent issue for users and this change aims to improve dx in dev mode by proactively warning about components that render a comment (ie. a fragment).

@antfu Can you think of a better way of checking this than inspecting the el with a setTimeout?

Note: this will only provide the warning on first render at the moment, rather than on subsequent navigation. Will need to look into how that can be done.

πŸ“ Checklist

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

@danielroe danielroe added the dx label Jun 15, 2022
@danielroe danielroe requested review from pi0 and antfu June 15, 2022 09:58
@danielroe danielroe self-assigned this Jun 15, 2022
@netlify
Copy link

netlify bot commented Jun 15, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit 34cf53a
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/6303b0f810a8d3000924129f

@antfu
Copy link
Member

antfu commented Jun 15, 2022

This is the method I could think of as well. Would nextTick, or onMounted be better than setTimeout?

@danielroe
Copy link
Member Author

I couldn't think of a way to access onMounted within the render function but feel free to implement if you have an idea - it would be more idiomatic (except note nuxt/nuxt#13471 - 🀦)!

@danielroe
Copy link
Member Author

This will only provide the warning on first render at the moment, rather than on subsequent navigation. Will need to look into how that can be done. (Marking as draft for that reason.)

@danielroe danielroe marked this pull request as draft June 16, 2022 10:21
@danielroe danielroe marked this pull request as ready for review August 4, 2022 23:07
@danielroe danielroe added the 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing label Aug 5, 2022
@pi0 pi0 merged commit cfb7e59 into main Aug 23, 2022
@pi0 pi0 deleted the dx/root-nodes branch August 23, 2022 10:25
@pi0 pi0 mentioned this pull request Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x dx 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing
Projects
None yet
3 participants