/** * `defineBuildConfig` and the types of a v1 module's `build.config.ts`, which * `@nuxt/module-builder` still exports for modules that have not moved to `builder()`. */ import type { PackageJson } from '../utils.ts' export interface BuildEntry { input: string name?: string builder?: 'rollup' | 'mkdist' outDir?: string [option: string]: unknown } /** The context passed to `build:before`, `rollup:done` and `build:done` hooks. */ export interface BuildContext { options: { name: string /** Absolute path of the module root. */ rootDir: string /** Absolute path of the output directory. */ outDir: string /** Every entry built, with absolute `input` and `outDir`, including `src/module` and `src/runtime/`. */ entries: Array declaration?: unknown stub: false sourcemap: boolean } pkg: PackageJson } export type BuildHook = (ctx: BuildContext) => void | Promise export interface BuildConfig { entries?: Array externals?: Array replace?: Record rollup?: Record hooks?: { 'build:before'?: BuildHook 'rollup:done'?: BuildHook 'build:done'?: BuildHook // eslint-disable-next-line @typescript-eslint/no-explicit-any } & Record unknown> [option: string]: unknown } /** * Type helper for a legacy `build.config.ts`, which `nuxt-module-build` still reads. * Supported options are `entries`, `externals`, `replace`, `rollup.replace`, `sourcemap` and * the `build:before`, `rollup:done` and `build:done` hooks. * * @deprecated `build.config.ts` will stop being read in a future major. Move `entries`, `externals` * and `replace` into `builder()` from `@nuxt/module-builder/tsdown`, in `tsdown.config.ts`, and * the hooks into tsdown's own `hooks`. See * https://github.com/nuxt/module-builder/blob/main/docs/upgrade-v2.md#moving-from-buildconfigts */ export function defineBuildConfig(config: T): T { return config }