Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

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

Merged
pi0 merged 12 commits into
mainfrom
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 into
mainfrom
dx/root-nodes

Conversation

@danielroe

@danielroedanielroe commented Jun 15, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#13828, resolvesnuxt/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 requested review from antfu and pi0June 15, 2022 09:58
@danielroedanielroe self-assigned this Jun 15, 2022
@netlify

netlifyBot commented Jun 15, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit34cf53a
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/6303b0f810a8d3000924129f

@antfu

Copy link
Copy Markdown
Member

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

@danielroe

Copy link
Copy Markdown
MemberAuthor

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
MemberAuthor

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
@danielroedanielroe added the 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing label Aug 5, 2022
Comment threadpackages/nuxt/src/app/components/layout.ts
pi0
pi0 approved these changes Aug 22, 2022
@pi0
pi0 merged commit cfb7e59 into mainAug 23, 2022
@pi0
pi0 deleted the dx/root-nodes branch August 23, 2022 10:25
@pi0pi0 mentioned this pull request Aug 26, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xdx🍰 p2-nice-to-havePriority 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

@danielroe@antfu@pi0