Skip to content
This repository was 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
pi0 merged 12 commits intomainfrom
dx/root-nodes
Aug 23, 2022
Merged

feat(nuxt): add warning in dev mode if layouts/pages do not have a single root node#5469
pi0 merged 12 commits intomainfrom
dx/root-nodes

Conversation

@danielroe
Copy link
Copy Markdown
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 antfu and pi0 June 15, 2022 09:58
@danielroe danielroe self-assigned this Jun 15, 2022
@netlify
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Comment thread packages/nuxt/src/app/components/layout.ts
@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

Development

Successfully merging this pull request may close these issues.

Warn needs to be much more specific when there's no root element in <template> Navigation fails if pages do not have single root element

3 participants