fix(nuxt): resolve `@unhead/vue` in template code (#23858)

This commit is contained in:
Daniel Roe 2023-10-22 09:39:56 +02:00 committed by GitHub
parent 06e6140953
commit d6c196afad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -48,9 +48,10 @@ export default defineNuxtModule({
})
// Opt-out feature allowing dependencies using @vueuse/head to work
const unheadVue = await tryResolveModule('@unhead/vue', nuxt.options.modulesDir) || '@unhead/vue'
if (nuxt.options.experimental.polyfillVueUseHead) {
// backwards compatibility
nuxt.options.alias['@vueuse/head'] = await tryResolveModule('@unhead/vue', nuxt.options.modulesDir) || '@unhead/vue'
nuxt.options.alias['@vueuse/head'] = unheadVue
addPlugin({ src: resolve(runtimeDir, 'plugins/vueuse-head-polyfill') })
}
@ -60,7 +61,7 @@ export default defineNuxtModule({
if (!nuxt.options.experimental.headNext) {
return 'export default []'
}
return `import { CapoPlugin } from '@unhead/vue';
return `import { CapoPlugin } from ${JSON.stringify(unheadVue)};
export default process.server ? [CapoPlugin({ track: true })] : [];`
}
})