Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nuxt): add useHeadSafe and remove layer around head imports #19548

Merged
merged 7 commits into from
Mar 10, 2023

Conversation

harlan-zw
Copy link
Contributor

@harlan-zw harlan-zw commented Mar 9, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 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)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

For some context, Nuxt 3 was initially built to support different head providers. Initially, it was providing support for @vueuse/head and Vue meta (although there was no way to opt-in to it).

With @vueuse/head moving towards deprecation and Nuxt going all-in on Unhead, it makes sense to clean up some of the technical debt introduced in supporting multiple head providers.

This technical debt can be summarised as:

  • #head alias - pointed towards where the head composables where for
  • #app re-exporting the #head composables - allowed nuxt internally to use any head provider

With this PR we move all head composables to the auto imports. For the Nxut app internal useHead calls, we import directly from @unhead/vue.

Inadvertibly we also are adding support for the new composable useHeadSafe so I have provided doc and tests for it.

⚠️ We are now deprecating importing useHead from #head or #app. Users should switch to importing from #imports. Also, we no longer recommend augmenting HeadAugmentations; instead, we can directly augment the Unhead schema if we want to add custom completions.

πŸ“ Checklist

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

@codesandbox
Copy link

codesandbox bot commented Mar 9, 2023

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

@harlan-zw harlan-zw changed the title chore(head): drop #head and #app imports for autoImportSources chore(head): drop #head and #app for auto-imports Mar 9, 2023
@harlan-zw harlan-zw changed the title chore(head): drop #head and #app for auto-imports perf(head): drop #head and #app for auto-imports Mar 9, 2023
@danielroe
Copy link
Member

This is great! To reduce breaking changes, do you think we can keep an export from #app that is marked as deprecated - and likewise, for HeadAugmentations - mark it as deprecated? We can then remove both in next minor: v3.4.

@danielroe danielroe added the 3.x label Mar 9, 2023
@danielroe
Copy link
Member

I've tentatively pushed a reversion of the breaking change in favour of deprecating the exports/interface, but happy to rethink if you think this isn't sensible. πŸ™

@danielroe danielroe added this to the v3.3 milestone Mar 9, 2023
@danielroe danielroe changed the title perf(head): drop #head and #app for auto-imports perf(nuxt): drop #head and #app for auto-imports Mar 10, 2023
@danielroe danielroe changed the title perf(nuxt): drop #head and #app for auto-imports feat(nuxt): add useHeadSafe and remove layer around head imports Mar 10, 2023
@danielroe danielroe merged commit c91e4d7 into main Mar 10, 2023
@danielroe danielroe deleted the chore/head-auto-imports branch March 10, 2023 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants