Skip to content

Commit 8d956fc

Browse files
committed
chore: broken unhead resolution
1 parent ea6e45b commit 8d956fc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/module.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@nuxt/kit'
1212
import { readPackageJSON } from 'pkg-types'
1313
import { lt, gte } from 'semver'
14-
import { join } from 'pathe'
14+
import { dirname, join } from 'pathe'
1515
import type { FetchOptions } from 'ofetch'
1616
import { setupDevToolsUI } from './devtools'
1717
import { NuxtScriptBundleTransformer } from './plugins/transform'
@@ -119,7 +119,10 @@ export default defineNuxtModule<ModuleOptions>({
119119
return
120120
}
121121
let isUnheadV2 = false
122-
const unheadPath = await resolvePath('@unhead/vue').catch(() => undefined)
122+
const unheadPath = await resolvePath('@unhead/vue')
123+
.catch(() => undefined)
124+
// compatibility
125+
.then(p => p?.endsWith('index.mjs') ? dirname(p) : p)
123126
// couldn't be found for some reason, assume compatibility
124127
if (unheadPath) {
125128
const { version: unheadVersion } = await readPackageJSON(join(unheadPath, 'package.json'))
@@ -129,7 +132,7 @@ export default defineNuxtModule<ModuleOptions>({
129132
else if (lt(unheadVersion, '1.11.5')) {
130133
logger.warn(`Nuxt Scripts recommends Unhead >= 1.11.5, you are using v${unheadVersion}. Please run \`nuxi upgrade --clean\` to upgrade...`)
131134
}
132-
else if (gte(unheadVersion, '^2')) {
135+
else if (gte(unheadVersion, '2.0.0-beta.1')) {
133136
isUnheadV2 = true
134137
}
135138
}

0 commit comments

Comments
 (0)