mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
fix(kit): add backward compatibility for deprecated module definition as function
This commit is contained in:
parent
05da4c2ef5
commit
5a7a979dcb
@ -13,6 +13,13 @@ import { templateUtils, compileTemplate } from '../internal/template'
|
|||||||
* any hooks that are provided, and calling an optional setup function for full control.
|
* any hooks that are provided, and calling an optional setup function for full control.
|
||||||
*/
|
*/
|
||||||
export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: ModuleDefinition<OptionsT>): NuxtModule<OptionsT> {
|
export function defineNuxtModule<OptionsT extends ModuleOptions> (definition: ModuleDefinition<OptionsT>): NuxtModule<OptionsT> {
|
||||||
|
// Legacy format. TODO: Remove in RC
|
||||||
|
if (typeof definition === 'function') {
|
||||||
|
// @ts-ignore
|
||||||
|
definition = definition(useNuxt())
|
||||||
|
consola.warn('Module definition as function is deprecated and will be removed in the future versions', definition)
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize definition and meta
|
// Normalize definition and meta
|
||||||
if (!definition.meta) { definition.meta = {} }
|
if (!definition.meta) { definition.meta = {} }
|
||||||
if (!definition.meta.configKey) {
|
if (!definition.meta.configKey) {
|
||||||
|
Loading…
Reference in New Issue
Block a user