fix(nuxt): do not try auto-install outside of a Nuxt context (#24605)

This commit is contained in:
Daniel Roe 2023-12-05 17:33:27 +00:00 committed by GitHub
parent 1e393ad696
commit 445fe808c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import { pascalCase } from 'scule'
import { resolve } from 'pathe'
import type { Component, ComponentsOptions } from 'nuxt/schema'
import { logger } from '@nuxt/kit'
import { logger, tryUseNuxt } from '@nuxt/kit'
import { distDir } from '../dirs'
import { isVue } from '../core/utils'
@ -47,7 +47,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
const component = findComponent(components, name, options.mode)
if (component) {
// @ts-expect-error TODO: refactor to nuxi
if (component._internal_install) {
if (component._internal_install && tryUseNuxt()?.options.test === false) {
// @ts-expect-error TODO: refactor to nuxi
import('../core/features').then(({ installNuxtModule }) => installNuxtModule(component._internal_install))
}