import { TypeScriptBuildOptions, TypeScriptBuildResolvedOptions, AdditionalCLIOptions } from '@storm-software/build-tools'; import { CommonOptions } from 'esbuild'; import { MkdistOptions } from 'mkdist'; import { BuildOptions, RollupBuildOptions, BuildContext, MkdistBuildEntry, BuildConfig } from 'unbuild'; type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; } : T; interface LoaderInputFile { path: string; extension: string; srcPath?: string; getContents: () => Promise | string; } interface LoaderOutputFile { /** * relative to distDir */ path: string; srcPath?: string; extension?: string; contents?: string; declaration?: boolean; errors?: Error[]; raw?: boolean; skip?: boolean; } type LoaderResult = LoaderOutputFile[] | undefined; type LoadFile = (input: LoaderInputFile) => LoaderResult | Promise; interface LoaderOptions { ext?: "js" | "mjs" | "cjs" | "ts" | "mts" | "cts"; format?: "cjs" | "esm"; declaration?: boolean; esbuild?: CommonOptions; postcss?: false | Record; } interface LoaderContext { loadFile: LoadFile; options: LoaderOptions; } type Loader = (input: LoaderInputFile, context: LoaderContext) => LoaderResult | Promise; type Loaders = ("js" | "vue" | "sass" | "postcss" | Loader)[]; type UnbuildOptions = Omit, "entries" | "rootDir" | "externals" | "rollupConfig" | "outDir" | "declaration" | "format" | "parallel"> & Omit & { /** * The directories to run the build process out of * * @defaultValue ["{sourceRoot}"] */ entry?: string[]; /** * Path to a rollup configuration file relative to the project root */ rollup?: string | DeepPartial; /** * Path to a unbuild configuration file relative to the project root */ configPath?: string; /** * Should the build process emit declaration files * * @defaultValue `true` */ dts?: boolean; /** * Should the build process skip generating a package.json and copying assets * * @defaultValue `false` */ buildOnly?: boolean; /** * The path to the TypeScript configuration file to use for the build process * * @defaultValue "{{projectRoot}}/tsconfig.json" */ tsconfig?: string; /** * Override the loader options used in the build process */ loaders?: Loaders | ((ctx: BuildContext, entry: MkdistBuildEntry, opts: MkdistOptions) => Loaders | Promise); }; type UnbuildResolvedOptions = Omit & BuildConfig & { /** * The path to the TypeScript configuration file to use for the build process */ tsconfig: string; /** * Path to a rollup configuration file relative to the project root */ rollup: DeepPartial; /** * Should the build process skip generating a package.json and copying assets * * @defaultValue `false` */ buildOnly?: boolean; outDir: string; externals: string[]; entries: BuildOptions["entries"]; declaration: BuildOptions["declaration"]; }; type UnbuildCLIOptions = AdditionalCLIOptions & Pick; export type { DeepPartial, LoadFile, Loader, LoaderContext, LoaderInputFile, LoaderOptions, LoaderOutputFile, LoaderResult, Loaders, UnbuildCLIOptions, UnbuildOptions, UnbuildResolvedOptions };