mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
feat(types): add declarations for ModuleContainer
utils (#9164)
This commit is contained in:
parent
88ea02c4fd
commit
2ec62617ce
39
packages/types/config/module.d.ts
vendored
39
packages/types/config/module.d.ts
vendored
@ -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<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 {
|
||||
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
|
||||
nuxt: any // TBD
|
||||
[key: string]: any // TBD
|
||||
|
Loading…
Reference in New Issue
Block a user