Skip to content

Commit bf39c4a

Browse files
committed
fix(script): honor aliased Unhead capabilities
1 parent 66edb9b commit bf39c4a

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

packages/script/src/module.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,19 @@ export default defineNuxtModule<ModuleOptions>({
608608
}
609609
}
610610
// If Unhead cannot be resolved, retain the compatibility implementation.
611-
const unheadPackagePath = await resolvePackageJSON('@unhead/vue', {
612-
// Match the package instance imported by the built runtime. An app can
613-
// contain another Unhead version with different loader capabilities.
614-
from: [resolveModule('./runtime')],
615-
}).catch(() => {
616-
// @unhead/vue is optional; unresolved installs use the local compatibility path.
617-
return null
618-
})
611+
const unheadScriptsAlias = nuxt.options.alias['@unhead/vue/scripts']
612+
const unheadPackagePath = await (typeof unheadScriptsAlias === 'string'
613+
? resolvePackageJSON(unheadScriptsAlias)
614+
: Promise.reject(new Error('No Unhead scripts alias')))
615+
.catch(() => resolvePackageJSON('@unhead/vue', {
616+
// Match the package instance imported by the built runtime. An app can
617+
// contain another Unhead version with different loader capabilities.
618+
from: [resolveModule('./runtime')],
619+
}))
620+
.catch(() => {
621+
// @unhead/vue is optional; unresolved installs use the local compatibility path.
622+
return null
623+
})
619624
const unheadPackage = unheadPackagePath
620625
? await readPackageJSON(unheadPackagePath).catch(() => {
621626
// An unreadable optional peer cannot safely advertise loader support.

0 commit comments

Comments
 (0)