fix(kit): add backward compatibility for deprecated module definition as function

This commit is contained in:
Pooya Parsa 2021-12-22 21:40:18 +01:00
parent 05da4c2ef5
commit 5a7a979dcb

View File

@ -13,6 +13,13 @@ import { templateUtils, compileTemplate } from '../internal/template'
* 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> {
// 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
if (!definition.meta) { definition.meta = {} }
if (!definition.meta.configKey) {