UNPKG

@roots/bud-extensions

Version:

bud.js core module

137 lines (136 loc) 4.14 kB
import type { Bud } from '@roots/bud-framework'; import { Extension, type ExtensionApi } from '@roots/bud-framework/extension'; type CompilerOptions = { baseUrl: string | undefined; outDir: string | undefined; paths: Record<string, Array<string>> | undefined; rootDir: string | undefined; }; type BudOptions = { useCompilerOptions?: boolean; }; type Options = { bud: BudOptions | undefined; compilerOptions: CompilerOptions | undefined; exclude: Array<string> | undefined; include: Array<string> | undefined; }; type Api = { getBud: () => Api['bud']; getCompilerOptions: () => Api['compilerOptions']; getExclude: () => Api['exclude']; getInclude: () => Api['include']; setBud: (bud: BudOptions) => Api; setCompilerOptions: (options: CompilerOptions) => Api; setExclude: (exclude: Array<string>) => Api; setInclude: (include: Array<string>) => Api; } & ExtensionApi<BudTsConfigValues, Options>; /** * The BudTsConfigValues class configures the bud.js application using settings * defined in a tsconfig.json file. This includes several options such as compilerOptions, * include, exclude, and a special bud key. The compilerOptions property provides configuration for the * TypeScript compiler, while include and exclude specify which files are to be included * in or excluded from the process. The bud property allows for enabling the use of compilerOptions. */ export default class BudTsConfigValues extends Extension<Options> implements Api { /** * tsconfig.json bud value */ bud: Api['bud']; /** * compilerOptions value * @see https://www.typescriptlang.org/tsconfig#compilerOptions */ compilerOptions: Api['compilerOptions']; /** * tsconfig.exclude value * @see https://www.typescriptlang.org/tsconfig#exclude */ exclude: Api['exclude']; /** * Get bud tsconfig.json value * @returns tsconfig.bud value */ getBud: Api['getBud']; /** * Get compilerOptions * @returns CompilerOptions * @see https://www.typescriptlang.org/tsconfig#compilerOptions */ getCompilerOptions: Api['getCompilerOptions']; /** * Get exclude * @returns exclude * @see https://www.typescriptlang.org/tsconfig#exclude */ getExclude: Api['getExclude']; /** * Get include * @returns include * @see https://www.typescriptlang.org/tsconfig#include */ getInclude: Api['getInclude']; /** * include value * @see https://www.typescriptlang.org/tsconfig#include */ include: Api['include']; /** * Set bud tsconfig.json value * @param options bud * @returns this */ setBud: Api['setBud']; /** * Set compilerOptions * @param options CompilerOptions * @returns this * @see https://www.typescriptlang.org/tsconfig#compilerOptions */ setCompilerOptions: Api['setCompilerOptions']; /** * Set exclude * @param options exclude * @returns this * @see https://www.typescriptlang.org/tsconfig#exclude */ setExclude: Api['setExclude']; /** * Set include * @param options include * @returns this * @see https://www.typescriptlang.org/tsconfig#include */ setInclude: Api['setInclude']; private get derivedBaseDir(); /** * The `configAfter` method adjusts the bud.js application * configuration by setting up paths and determining file inclusion and exclusion * based on the tsconfig.json settings. * * {@link Extension.configAfter} */ configAfter(bud: Bud): Promise<void>; /** * Make absolute path * * @param path string * @returns string */ private makeAbsolute; /** * Resolve {@link CompilerOptions.paths} against {@link BudTsConfigValues.derivedBaseDir} * * @remarks * Operates on the first item in the array of paths * * @param paths * @returns */ private normalizePaths; /** * {@link Extension.register} */ register(bud: Bud): Promise<void>; } export {};