diff --git a/packages/types/config/module.d.ts b/packages/types/config/module.d.ts index fb97c8f1de..c60245b6bf 100644 --- a/packages/types/config/module.d.ts +++ b/packages/types/config/module.d.ts @@ -6,6 +6,8 @@ import { Configuration as WebpackConfiguration } from 'webpack' import { NuxtOptionsLoaders } from './build' +import { NuxtRouteConfig } from './router' +import { NuxtOptionsServerMiddleware } from './server-middleware' import { NuxtOptions } from '.' interface ExtendFunctionContext { @@ -17,10 +19,43 @@ interface ExtendFunctionContext { loaders: NuxtOptionsLoaders } -type ExtendFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void +export interface ModuleTemplateConfig { + src: string, + fileName?: string + filename?: string + options?: Record + [key: string]: any +} + +export interface ModulePluginTemplateConfig extends ModuleTemplateConfig { + ssr?: boolean + mode?: 'all' | 'client' | 'server' +} + +export interface ModuleTemplateDest { + src: string + dst: string + options?: Record +} + +export type ModuleTemplate = ModuleTemplateConfig | string +export type ModulePluginTemplate = ModulePluginTemplateConfig | string + +type ExtendRoutesFunction = (routes: NuxtRouteConfig[], resolve: (...pathSegments: string[]) => string) => void +type ExtendBuildFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void interface ModuleThis { - extendBuild(fn: ExtendFunction): void + addTemplate(template: ModuleTemplate): ModuleTemplateDest + addPlugin(template: ModulePluginTemplate): void + addLayout(template: ModuleTemplate, name?: string): void + addErrorLayout (dst: string): void + addServerMiddleware (middleware: NuxtOptionsServerMiddleware): void + extendBuild(fn: ExtendBuildFunction): void + extendRoutes(fn: ExtendRoutesFunction): void + // eslint-disable-next-line no-use-before-define + requireModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise + // eslint-disable-next-line no-use-before-define + addModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise options: NuxtOptions nuxt: any // TBD [key: string]: any // TBD