Skip to content

Commit

Permalink
fix: @unhead/vue import breaking start
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed May 6, 2024
1 parent 858c25e commit d52249d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ export default defineNuxtModule<ModuleOptions>({
async setup(config, nuxt) {
const { resolve } = createResolver(import.meta.url)
const { version, name } = await readPackageJSON(resolve('../package.json'))
const { version: unheadVersion } = await readPackageJSON(join(await resolvePath('@unhead/vue'), 'package.json'))

if (!unheadVersion || lt(unheadVersion, '1.8.0')) {
logger.warn('@nuxt/scripts requires @unhead/vue >= 1.8.0, please upgrade to use the module.')
return
const unheadPath = await resolvePath('@unhead/vue')
// couldn't be found for some reason, assume compatibility
if (unheadPath) {
const { version: unheadVersion } = await readPackageJSON(join(await resolvePath('@unhead/vue'), 'package.json'))
if (!unheadVersion || lt(unheadVersion, '1.9.0')) {
logger.warn('@nuxt/scripts requires @unhead/vue >= 1.9.0, please upgrade to use the module.')
return
}
}
if (!config.enabled) {
// TODO fallback to useHead?
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/composables/useScript.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type UseScriptInput, type VueScriptInstance, useScript as _useScript, injectHead } from '@unhead/vue'
import type { UseScriptInput, VueScriptInstance } from '@unhead/vue'
import type { UseScriptOptions } from '@unhead/schema'
import { hashCode } from '@unhead/shared'
import { defu } from 'defu'
import { onNuxtReady, useNuxtApp, useRuntimeConfig } from '#imports'
import { useScript as _useScript, injectHead, onNuxtReady, useNuxtApp, useRuntimeConfig } from '#imports'
import type { NuxtAppScript, NuxtUseScriptOptions } from '#nuxt-scripts'

function useNuxtScriptRuntimeConfig() {
Expand Down

0 comments on commit d52249d

Please sign in to comment.