mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(kit): support calling Nuxt 2 modules with module container (#20023)
This commit is contained in:
parent
8908aa7c5a
commit
b1826ee9f4
@ -1,4 +1,5 @@
|
|||||||
import type { Nuxt, NuxtModule } from '@nuxt/schema'
|
import type { Nuxt, NuxtModule } from '@nuxt/schema'
|
||||||
|
import { isNuxt2 } from '../compatibility'
|
||||||
import { useNuxt } from '../context'
|
import { useNuxt } from '../context'
|
||||||
import { resolveModule, requireModule } from '../internal/cjs'
|
import { resolveModule, requireModule } from '../internal/cjs'
|
||||||
import { importModule } from '../internal/esm'
|
import { importModule } from '../internal/esm'
|
||||||
@ -10,7 +11,12 @@ export async function installModule (moduleToInstall: string | NuxtModule, _inli
|
|||||||
const { nuxtModule, inlineOptions } = await normalizeModule(moduleToInstall, _inlineOptions)
|
const { nuxtModule, inlineOptions } = await normalizeModule(moduleToInstall, _inlineOptions)
|
||||||
|
|
||||||
// Call module
|
// Call module
|
||||||
const res = await nuxtModule(inlineOptions, nuxt) ?? {}
|
const res = (
|
||||||
|
isNuxt2()
|
||||||
|
// @ts-expect-error Nuxt 2 `moduleContainer` is not typed
|
||||||
|
? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt)
|
||||||
|
: await nuxtModule(inlineOptions, nuxt)
|
||||||
|
) ?? {}
|
||||||
if (res === false /* setup aborted */) {
|
if (res === false /* setup aborted */) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user