mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
refactor(nuxt): use direct import of installNuxtModule
This commit is contained in:
parent
98c28db411
commit
501ccc3750
@ -7,6 +7,7 @@ import type { Component, ComponentsOptions } from 'nuxt/schema'
|
||||
|
||||
import { logger, tryUseNuxt } from '@nuxt/kit'
|
||||
import { QUOTE_RE, SX_RE, isVue } from '../../core/utils'
|
||||
import { installNuxtModule } from '../../core/features'
|
||||
|
||||
interface LoaderOptions {
|
||||
getComponents (): Component[]
|
||||
@ -54,7 +55,7 @@ export const LoaderPlugin = (options: LoaderOptions) => createUnplugin(() => {
|
||||
const relativePath = relative(nuxt.options.rootDir, id)
|
||||
throw new Error(`[nuxt] \`~/${relativePath}\` is using \`${component.pascalName}\` which requires \`${internalInstall}\``)
|
||||
}
|
||||
import('../../core/features').then(({ installNuxtModule }) => installNuxtModule(internalInstall))
|
||||
installNuxtModule(internalInstall)
|
||||
}
|
||||
let identifier = map.get(component) || `__nuxt_component_${num++}`
|
||||
map.set(component, identifier)
|
||||
|
@ -21,6 +21,7 @@ import defu from 'defu'
|
||||
import { gt, satisfies } from 'semver'
|
||||
import { hasTTY, isCI } from 'std-env'
|
||||
|
||||
import { installNuxtModule } from '../core/features'
|
||||
import pagesModule from '../pages/module'
|
||||
import metaModule from '../head/module'
|
||||
import componentsModule from '../components/module'
|
||||
@ -237,7 +238,7 @@ async function initNuxt (nuxt: Nuxt) {
|
||||
// @ts-expect-error scripts types are not present as the module is not installed
|
||||
if (nuxt.options.scripts) {
|
||||
if (!nuxt.options._modules.some(m => m === '@nuxt/scripts' || m === '@nuxt/scripts-nightly')) {
|
||||
await import('../core/features').then(({ installNuxtModule }) => installNuxtModule('@nuxt/scripts'))
|
||||
installNuxtModule('@nuxt/scripts')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,9 @@ import type { Unimport } from 'unimport'
|
||||
import { normalize } from 'pathe'
|
||||
import { tryUseNuxt } from '@nuxt/kit'
|
||||
import type { ImportsOptions } from 'nuxt/schema'
|
||||
|
||||
import { isJS, isVue } from '../core/utils'
|
||||
import { installNuxtModule } from '../core/features'
|
||||
|
||||
const NODE_MODULES_RE = /[\\/]node_modules[\\/]/
|
||||
const IMPORTS_RE = /(['"])#imports\1/
|
||||
@ -40,7 +42,7 @@ export const TransformPlugin = ({ ctx, options, sourcemap }: { ctx: Unimport, op
|
||||
|
||||
const { s, imports } = await ctx.injectImports(code, id, { autoImport: options.autoImport && !isNodeModule })
|
||||
if (imports.some(i => i.from === '#app/composables/script-stubs') && tryUseNuxt()?.options.test === false) {
|
||||
import('../core/features').then(({ installNuxtModule }) => installNuxtModule('@nuxt/scripts'))
|
||||
installNuxtModule('@nuxt/scripts')
|
||||
}
|
||||
|
||||
if (s.hasChanged()) {
|
||||
|
Loading…
Reference in New Issue
Block a user