From 5a7a979dcb4dc74e92cce2c9c9bbddbb52a0d3d5 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 22 Dec 2021 21:40:18 +0100 Subject: [PATCH] fix(kit): add backward compatibility for deprecated module definition as function --- packages/kit/src/module/define.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/kit/src/module/define.ts b/packages/kit/src/module/define.ts index 0ae88e614f..345b0f2a41 100644 --- a/packages/kit/src/module/define.ts +++ b/packages/kit/src/module/define.ts @@ -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 (definition: ModuleDefinition): NuxtModule { + // 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) {