@farmfe/core
Version:
Farm is a extremely fast web build tool written in Rust. Farm can start a project in milliseconds and perform HMR within 10ms, making it much faster than similar tools like webpack and vite.
56 lines (55 loc) • 3.26 kB
TypeScript
import { JsPlugin } from '../index.js';
import { Logger } from '../utils/index.js';
import { CompilationMode } from './env.js';
import type { FarmCLIOptions, NormalizedServerConfig, ResolvedCompilation, ResolvedUserConfig, UserConfig, UserConfigExport, UserConfigFnObject, UserHmrConfig, UserServerConfig } from './types.js';
export * from './types.js';
export declare function defineFarmConfig(config: UserConfig): UserConfig;
export declare function defineFarmConfig(config: Promise<UserConfig>): Promise<UserConfig>;
export declare function defineFarmConfig(config: UserConfigFnObject): UserConfigFnObject;
export declare function defineFarmConfig(config: UserConfigExport): UserConfigExport;
/**
* Resolve and load user config from the specified path
* @param configPath
*/
export declare function resolveConfig(inlineOptions?: FarmCLIOptions & UserConfig, mode?: CompilationMode, logger?: Logger, isHandleServerPortConflict?: boolean): Promise<ResolvedUserConfig>;
/**
* Normalize user config and transform it to rust compiler compatible config
*
*
* ResolvedUserConfig is a parameter passed to rust Compiler,
* and ResolvedUserConfig is generated from UserConfig.
* When UserConfig is different from ResolvedUserConfig,
* a legal value should be given to the ResolvedUserConfig field here,
* and converted from UserConfig in the subsequent process.
*
* @param config
* @returns resolved config that parsed to rust compiler
*/
export declare function normalizeUserCompilationConfig(resolvedUserConfig: ResolvedUserConfig, userConfig: UserConfig, logger: Logger, mode?: CompilationMode, isDefault?: boolean): Promise<ResolvedCompilation>;
export declare const DEFAULT_HMR_OPTIONS: Required<UserHmrConfig>;
export declare const DEFAULT_DEV_SERVER_OPTIONS: NormalizedServerConfig;
export declare const DEFAULT_COMPILATION_OPTIONS: Partial<ResolvedCompilation>;
export declare function normalizeDevServerConfig(options: UserServerConfig | undefined, mode: string): NormalizedServerConfig;
export declare function normalizePublicDir(root: string, userPublicDir?: string): string;
export declare function checkClearScreen(inlineConfig: FarmCLIOptions | ResolvedUserConfig): void;
export declare function resolveMergedUserConfig(mergedUserConfig: UserConfig, configFilePath: string | undefined, mode: 'development' | 'production' | string, logger?: Logger): Promise<ResolvedUserConfig>;
/**
* Load config file from the specified path and return the config and config file path
* @param configPath the config path, could be a directory or a file
* @param logger custom logger
* @returns loaded config and config file path
*/
export declare function loadConfigFile(configPath: string, inlineOptions: FarmCLIOptions, mode?: CompilationMode, logger?: Logger): Promise<{
config: UserConfig;
configFilePath: string;
} | undefined>;
export declare function getConfigFilePath(configPath: string): Promise<string | undefined>;
export declare function resolvePlugins(userConfig: UserConfig, logger: Logger, mode: CompilationMode): Promise<{
jsPlugins: JsPlugin[];
vitePlugins: (object | (() => {
vitePlugin: any;
filters: string[];
}))[];
rustPlugins: [string, string][];
vitePluginAdapters: JsPlugin[];
}>;