@junobuild/cli-tools
Version:
A collection of tools for Juno CLIs and Plugins.
62 lines (61 loc) • 2.23 kB
TypeScript
import type { Message, Metafile, OutputFile } from 'esbuild';
/**
* Builds the serverless functions using `esbuild`.
*
* This feature:
* - Ensures `esbuild` is available.
* - Deletes the existing output file if it exists.
* - Builds the input file with optimizations: minification, tree-shaking, etc.
* - Returns the esbuild `metafile`, version, and any build errors or warnings.
*
* @param {Object} options - Build configuration.
* @param {string} options.infile - The path to the input file to be bundled.
* @param {string} options.outfile - The path where the output bundle should be written.
* @param {Object<string, string>} [options.banner] - Optional banner to prepend to the generated file.
*
* @returns {Promise<{
* metafile: Metafile,
* errors: Message[],
* warnings: Message[],
* version: string
* }>} An object containing the esbuild metafile, build errors/warnings, and the version of esbuild used.
*
* @throws Will exit the process if `esbuild` is not installed.
*/
export declare const buildFunctions: ({ infile, banner }: {
infile: string;
banner?: {
[type: string]: string;
};
}) => Promise<EsbuildResult>;
/**
* Builds a script using `esbuild` for `juno run`.
*
* This feature:
* - Ensures `esbuild` is available.
* - Builds the input file for Node with optimizations: minification, tree-shaking, etc.
* - Returns the esbuild output files, `metafile`, version, and any build errors or warnings.
*
* @param {Object} options - Build configuration.
* @param {string} options.infile - The path to the input file to be bundled.
*
* @returns {Promise<{
* metafile: Metafile,
* errors: Message[],
* warnings: Message[],
* version: string,
* outputFiles: OutputFile[] | undefined;
* }>} An object containing the esbuild outputFiles, metafile, build errors/warnings, and the version of esbuild used.
*
* @throws Will exit the process if `esbuild` is not installed.
*/
export declare const buildScript: ({ infile }: {
infile: string;
}) => Promise<EsbuildResult>;
export interface EsbuildResult {
metafile: Metafile;
errors: Message[];
warnings: Message[];
version: string;
outputFiles: OutputFile[] | undefined;
}