UNPKG

@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.

21 lines 1.03 kB
import { performance } from 'node:perf_hooks'; import { FARM_TARGET_NODE_ENVS, clearScreen } from '../index.js'; import { logError } from '../server/error.js'; import { PersistentCacheBrand, bold, green } from './color.js'; export async function compilerHandler(callback, config, logger, options) { const IS_TARGET_NODE = FARM_TARGET_NODE_ENVS.includes(config.compilation.output.targetEnv); IS_TARGET_NODE && options?.clear && clearScreen(); const { persistentCache, output } = config.compilation; const startTime = performance.now(); try { await callback(); } catch (error) { logger.error(`Compiler ${logError(error, false)}`); return; } const elapsedTime = Math.floor(performance.now() - startTime); const persistentCacheText = persistentCache ? bold(PersistentCacheBrand) : ''; logger.info(`Build completed in ${bold(green(`${elapsedTime}ms`))} ${persistentCacheText} Resources emitted to ${bold(green(output.path))}.`); } //# sourceMappingURL=build.js.map