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

refactor(nuxt)!: move head option support into defineNuxtComponent#8901

Merged
pi0 merged 6 commits intomainfrom
fix/head-options
Nov 15, 2022
Merged

refactor(nuxt)!: move head option support into defineNuxtComponent#8901
pi0 merged 6 commits intomainfrom
fix/head-options

Conversation

@danielroe
Copy link
Copy Markdown
Member

@danielroe danielroe commented Nov 10, 2022

🔗 Linked issue

https://github.com/nuxt/framework/discussions/8874

❓ 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 PR moves support for head option into defineNuxtComponent to allow proper tree-shaking of used composables and avoid registering a global mixin that runs on every single component.

This PR also removes legacy support for useMeta which has been deprecated for some time. useHead is a drop-in replacement.

👉 Migration

Anywhere you are using the Options API head hook, you can instead wrap the component with defineNuxtComponent. (Or alternatively you may decide to use a component like <Meta>, <Link>, etc.)

Anywhere you are using useMeta, you should replace useHead.

📝 Checklist

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

@danielroe danielroe added bug Something isn't working performance labels Nov 10, 2022
@danielroe danielroe requested a review from pi0 November 10, 2022 17:33
@danielroe danielroe self-assigned this Nov 10, 2022
@codesandbox
Copy link
Copy Markdown

codesandbox Bot commented Nov 10, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link
Copy Markdown

netlify Bot commented Nov 10, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit da192b5
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/6373727bfbd428000745d682

@harlan-zw
Copy link
Copy Markdown
Collaborator

Oh nice, this is a good idea.

I'll make the mixin from #8908 opt-in

@harlan-zw harlan-zw mentioned this pull request Nov 11, 2022
7 tasks
@danielroe danielroe marked this pull request as draft November 11, 2022 10:13
@pi0
Copy link
Copy Markdown
Member

pi0 commented Nov 15, 2022

Any updates on this? 🙏🏼 What is a blocker?

@harlan-zw
Copy link
Copy Markdown
Collaborator

lgtm

@danielroe
Copy link
Copy Markdown
Member Author

The issue at the moment is that this PR produces a separate, tiny _nuxt/composables.js chunk.

@danielroe
Copy link
Copy Markdown
Member Author

I've looked into this a bit further and it seems inevitable from a rollup point of view, even if we were to move useHead into #app directly. The issue is that the error components (dynamically imported) are importing only useHead from app and rollup therefore produces a tiny shared chunk. We may be able to refine behaviour with manualChunks in future but I think it should be okay for now, and not replicable if a user is using their own error.vue.

@danielroe danielroe marked this pull request as ready for review November 15, 2022 11:10
@pi0 pi0 merged commit 2c2fbdf into main Nov 15, 2022
@pi0 pi0 deleted the fix/head-options branch November 15, 2022 14:47
@pi0 pi0 mentioned this pull request Nov 16, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants