feat(types): add declarations for ModuleContainer utils (#9164)

This commit is contained in:
Shogo Kawahara 2021-04-19 16:33:13 +09:00 committed by GitHub
parent 88ea02c4fd
commit 2ec62617ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,8 @@
import { Configuration as WebpackConfiguration } from 'webpack' import { Configuration as WebpackConfiguration } from 'webpack'
import { NuxtOptionsLoaders } from './build' import { NuxtOptionsLoaders } from './build'
import { NuxtRouteConfig } from './router'
import { NuxtOptionsServerMiddleware } from './server-middleware'
import { NuxtOptions } from '.' import { NuxtOptions } from '.'
interface ExtendFunctionContext { interface ExtendFunctionContext {
@ -17,10 +19,43 @@ interface ExtendFunctionContext {
loaders: NuxtOptionsLoaders loaders: NuxtOptionsLoaders
} }
type ExtendFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void export interface ModuleTemplateConfig {
src: string,
fileName?: string
filename?: string
options?: Record<string, any>
[key: string]: any
}
export interface ModulePluginTemplateConfig extends ModuleTemplateConfig {
ssr?: boolean
mode?: 'all' | 'client' | 'server'
}
export interface ModuleTemplateDest {
src: string
dst: string
options?: Record<string, any>
}
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 { 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<any>
// eslint-disable-next-line no-use-before-define
addModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise<any>
options: NuxtOptions options: NuxtOptions
nuxt: any // TBD nuxt: any // TBD
[key: string]: any // TBD [key: string]: any // TBD