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

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

Merged
merged 6 commits into from Nov 15, 2022

Conversation

danielroe
Copy link
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

codesandbox bot commented Nov 10, 2022

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

@netlify
Copy link

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
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
Member

pi0 commented Nov 15, 2022

Any updates on this? πŸ™πŸΌ What is a blocker?

@harlan-zw
Copy link
Collaborator

lgtm

@danielroe
Copy link
Member Author

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

@danielroe
Copy link
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.

None yet

3 participants