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-
constunheadPackagePath=awaitresolvePackageJSON('@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-
returnnull
618-
})
611+
constunheadScriptsAlias=nuxt.options.alias['@unhead/vue/scripts']
612+
constunheadPackagePath=await(typeofunheadScriptsAlias==='string'
613+
? resolvePackageJSON(unheadScriptsAlias)
614+
: Promise.reject(newError('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+
returnnull
623+
})
619624
constunheadPackage=unheadPackagePath
620625
? awaitreadPackageJSON(unheadPackagePath).catch(()=>{
621626
// An unreadable optional peer cannot safely advertise loader support.

0 commit comments

Comments
 (0)