fix(kit)!: do not check compatibility for nuxt version < 2.13

This commit is contained in:
Daniel Roe 2025-01-21 14:53:09 +00:00
parent 6abefd3ee6
commit f94cda4c80
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -1,7 +1,6 @@
import { kebabCase, pascalCase } from 'scule' import { kebabCase, pascalCase } from 'scule'
import type { Component, ComponentsDir } from '@nuxt/schema' import type { Component, ComponentsDir } from '@nuxt/schema'
import { useNuxt } from './context' import { useNuxt } from './context'
import { checkNuxtVersion } from './compatibility'
import { logger } from './logger' import { logger } from './logger'
import { MODE_RE } from './utils' import { MODE_RE } from './utils'
@ -10,9 +9,6 @@ import { MODE_RE } from './utils'
*/ */
export function addComponentsDir (dir: ComponentsDir, opts: { prepend?: boolean } = {}) { export function addComponentsDir (dir: ComponentsDir, opts: { prepend?: boolean } = {}) {
const nuxt = useNuxt() const nuxt = useNuxt()
if (!checkNuxtVersion('>=2.13', nuxt)) {
throw new Error(`\`addComponentsDir\` requires Nuxt 2.13 or higher.`)
}
nuxt.options.components ||= [] nuxt.options.components ||= []
dir.priority ||= 0 dir.priority ||= 0
nuxt.hook('components:dirs', (dirs) => { dirs[opts.prepend ? 'unshift' : 'push'](dir) }) nuxt.hook('components:dirs', (dirs) => { dirs[opts.prepend ? 'unshift' : 'push'](dir) })
@ -27,10 +23,6 @@ export type AddComponentOptions = { name: string, filePath: string } & Partial<E
*/ */
export function addComponent (opts: AddComponentOptions) { export function addComponent (opts: AddComponentOptions) {
const nuxt = useNuxt() const nuxt = useNuxt()
if (!checkNuxtVersion('>=2.13', nuxt)) {
throw new Error(`\`addComponent\` requires Nuxt 2.13 or higher.`)
}
nuxt.options.components ||= [] nuxt.options.components ||= []
if (!opts.mode) { if (!opts.mode) {