///
///
import { Stats } from 'fs';
import * as url from 'url';
export declare interface Analyze {
/**
* Generate metafile for analysis
*/
metafile?: boolean;
/**
* Generate stats for analysis, Default is `false`;
* @type {boolean} - Only generate `stat.json`.
* @type {'server'} - Generate `stat.json` and open it in browser.
* @type {Record} - Use `server` and configure it.
*/
stats?: boolean | 'server' | {
/**
* Open Browser auto, default is `true`.
*/
openBrowser?: boolean;
};
}
/**
* Pretty-prints an analysis of the metafile JSON to a string. This is just for
* convenience to be able to match esbuild's pretty-printing exactly. If you want
* to customize it, you can just inspect the data in the metafile yourself.
*
* - Works in node: yes
* - Works in browser: yes
*
* Documentation: https://esbuild.github.io/api/#analyze
*/
declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise;
declare interface AnalyzeMetafileOptions {
color?: boolean;
verbose?: boolean;
}
/**
* A synchronous version of "analyzeMetafile".
*
* - Works in node: yes
* - Works in browser: no
*
* Documentation: https://esbuild.github.io/api/#analyze
*/
declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
export declare type AnalyzeNormalized = Required;
declare type Append = {
0: [U];
1: [T[0], U];
2: [T[0], T[1], U];
3: [T[0], T[1], T[2], U];
4: [T[0], T[1], T[2], T[3], U];
5: [T[0], T[1], T[2], T[3], T[4], U];
6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
}[Measure];
declare type ArgumentNames = FixedSizeArray;
declare type AsArray = T extends any[] ? T : [T];
export declare interface Asset {
test?: RegExp;
name?: string | Record | ((resourcePath: string, resourceQuery: Record, type: AssetType) => string);
limit?: number;
raw?: Raw;
}
export declare type AssetChunk = {
type: 'asset';
contents: string | Buffer;
fileName: string;
originalFileName?: string;
entryPoint?: string;
};
export declare type AssetType = 'image' | 'svg' | 'lottie' | 'lottie-image' | 'file' | 'font' | 'media' | 'style';
declare class AsyncHook extends Hook {
tapAsync(
options: string | Tap & IfSet,
fn: (...args: Append, InnerCallback>) => void
): void;
tapPromise(
options: string | Tap & IfSet,
fn: (...args: AsArray) => Promise
): void;
}
declare class AsyncSeriesBailHook extends AsyncHook {}
declare class AsyncSeriesHook extends AsyncHook {}
declare class AsyncSeriesWaterfallHook extends AsyncHook[0], AdditionalOptions> {}
/**
* This function invokes the "esbuild" command-line tool for you. It returns a
* promise that either resolves with a "BuildResult" object or rejects with a
* "BuildFailure" object.
*
* - Works in node: yes
* - Works in browser: yes
*
* Documentation: https://esbuild.github.io/api/#build-api
*/
declare function build(options: BuildOptions & { write: false }): Promise;
declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise;
declare function build(options: BuildOptions & { incremental: true }): Promise;
declare function build(options: BuildOptions & { metafile: true }): Promise;
declare function build(options: BuildOptions): Promise;
export declare interface BuildConfig extends Required> {
logger: ILogger;
analyze: AnalyzeNormalized;
resolve: ResolveNormalized;
output: OutputNormalized;
dev: DevServerNormalized | false;
terserOptions?: TerserMinifyOptions;
css_resolve: (id: string, dir: string) => string;
node_resolve: (id: string, dir: string) => string;
}
declare interface BuildFailure extends Error {
errors: Message[];
warnings: Message[];
}
declare interface BuildIncremental extends BuildResult {
rebuild: BuildInvalidate;
}
declare interface BuildInvalidate {
(): Promise;
dispose(): void;
}
declare interface BuildOptions extends CommonOptions {
/** Documentation: https://esbuild.github.io/api/#bundle */
bundle?: boolean;
/** Documentation: https://esbuild.github.io/api/#splitting */
splitting?: boolean;
/** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
preserveSymlinks?: boolean;
/** Documentation: https://esbuild.github.io/api/#outfile */
outfile?: string;
/** Documentation: https://esbuild.github.io/api/#metafile */
metafile?: boolean;
/** Documentation: https://esbuild.github.io/api/#outdir */
outdir?: string;
/** Documentation: https://esbuild.github.io/api/#outbase */
outbase?: string;
/** Documentation: https://esbuild.github.io/api/#platform */
platform?: Platform;
/** Documentation: https://esbuild.github.io/api/#external */
external?: string[];
/** Documentation: https://esbuild.github.io/api/#loader */
loader?: { [ext: string]: Loader };
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */
resolveExtensions?: string[];
/** Documentation: https://esbuild.github.io/api/#mainFields */
mainFields?: string[];
/** Documentation: https://esbuild.github.io/api/#conditions */
conditions?: string[];
/** Documentation: https://esbuild.github.io/api/#write */
write?: boolean;
/** Documentation: https://esbuild.github.io/api/#allow-overwrite */
allowOverwrite?: boolean;
/** Documentation: https://esbuild.github.io/api/#tsconfig */
tsconfig?: string;
/** Documentation: https://esbuild.github.io/api/#out-extension */
outExtension?: { [ext: string]: string };
/** Documentation: https://esbuild.github.io/api/#public-path */
publicPath?: string;
/** Documentation: https://esbuild.github.io/api/#entry-names */
entryNames?: string;
/** Documentation: https://esbuild.github.io/api/#chunk-names */
chunkNames?: string;
/** Documentation: https://esbuild.github.io/api/#asset-names */
assetNames?: string;
/** Documentation: https://esbuild.github.io/api/#inject */
inject?: string[];
/** Documentation: https://esbuild.github.io/api/#banner */
banner?: { [type: string]: string };
/** Documentation: https://esbuild.github.io/api/#footer */
footer?: { [type: string]: string };
/** Documentation: https://esbuild.github.io/api/#incremental */
incremental?: boolean;
/** Documentation: https://esbuild.github.io/api/#entry-points */
entryPoints?: string[] | Record;
/** Documentation: https://esbuild.github.io/api/#stdin */
stdin?: StdinOptions;
/** Documentation: https://esbuild.github.io/plugins/ */
plugins?: Plugin[];
/** Documentation: https://esbuild.github.io/api/#working-directory */
absWorkingDir?: string;
/** Documentation: https://esbuild.github.io/api/#node-paths */
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
/** Documentation: https://esbuild.github.io/api/#watch */
watch?: boolean | WatchMode;
}
declare interface BuildResult {
errors: Message[];
warnings: Message[];
/** Only when "write: false" */
outputFiles?: OutputFile[];
/** Only when "incremental: true" */
rebuild?: BuildInvalidate;
/** Only when "watch: true" */
stop?: () => void;
/** Only when "metafile: true" */
metafile?: Metafile;
/** Only when "mangleCache" is present */
mangleCache?: Record;
}
/**
* A synchronous version of "build".
*
* - Works in node: yes
* - Works in browser: no
*
* Documentation: https://esbuild.github.io/api/#build-api
*/
declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] };
declare function buildSync(options: BuildOptions): BuildResult;
export declare interface BundleAsset {
name: string;
size: number;
emitted: boolean;
chunks: Array;
chunkNames: Array;
}
export declare interface BundleChunk {
id: ID;
entry: boolean;
initial: boolean;
children: number[];
files: string[];
modules?: BundleModule[];
names: string[];
origins?: Array<{
moduleId?: ID;
module: string;
moduleName: string;
request: string;
reasons: string[];
}>;
reason?: string;
rendered: boolean;
size: number;
siblings: number[];
}
export declare interface BundleChunkGroup {
assets: string[];
chunks: Array;
children: Record;
name: string;
}>;
childAssets: Record;
}
export declare interface BundleModule {
assets?: string[];
chunks: Array;
size?: number;
id: ID;
identifier: string;
issuer: string | undefined;
issuerId: ID | undefined;
issuerName: string | undefined;
issuerPath: Array<{
id: ID;
identifier: string;
name: string;
}>;
modules: BundleModule[];
name: string;
providedExports?: any;
reasons: ModuleReason[];
usedExports?: boolean;
}
export declare interface Cache {
/**
* enable transform cache.
* @default true
*/
transform?: boolean;
}
export declare interface CacheValue extends Source {
originCode: string;
}
export declare type Callback = (err?: any) => void;
declare type Callback_2 = (error: E | null, result?: T) => void;
declare type Charset = 'ascii' | 'utf8';
export declare type Chunk = AssetChunk | JsChunk;
export declare const enum ChunkType {
chunk = "chunk",
asset = "asset"
}
export declare interface CLIConfig extends UserConfig {
/**
* project root dir
*/
root?: string;
/**
* The path of config file, default by `speedy.config.js`.
*
* - `false` means do not read any config file.
*/
configFile?: string | false;
/**
* The mode of cli.
*/
command?: Command;
}
export declare interface CodeFrameOption {
filePath: string;
fileContent: string;
range: FrameRange;
}
/**
* - `'serve'` will enable devPlugin, which will start a server.
* - `'build'` is default options.
*/
export declare type Command = 'serve' | 'build';
declare interface CommonOptions {
/** Documentation: https://esbuild.github.io/api/#sourcemap */
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
/** Documentation: https://esbuild.github.io/api/#legal-comments */
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external';
/** Documentation: https://esbuild.github.io/api/#source-root */
sourceRoot?: string;
/** Documentation: https://esbuild.github.io/api/#sources-content */
sourcesContent?: boolean;
/** Documentation: https://esbuild.github.io/api/#format */
format?: Format_2;
/** Documentation: https://esbuild.github.io/api/#globalName */
globalName?: string;
/** Documentation: https://esbuild.github.io/api/#target */
target?: string | string[];
/** Documentation: https://esbuild.github.io/api/#mangle-props */
mangleProps?: RegExp;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
reserveProps?: RegExp;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
mangleQuoted?: boolean;
/** Documentation: https://esbuild.github.io/api/#mangle-props */
mangleCache?: Record;
/** Documentation: https://esbuild.github.io/api/#drop */
drop?: Drop[];
/** Documentation: https://esbuild.github.io/api/#minify */
minify?: boolean;
/** Documentation: https://esbuild.github.io/api/#minify */
minifyWhitespace?: boolean;
/** Documentation: https://esbuild.github.io/api/#minify */
minifyIdentifiers?: boolean;
/** Documentation: https://esbuild.github.io/api/#minify */
minifySyntax?: boolean;
/** Documentation: https://esbuild.github.io/api/#charset */
charset?: Charset;
/** Documentation: https://esbuild.github.io/api/#tree-shaking */
treeShaking?: boolean;
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */
ignoreAnnotations?: boolean;
/** Documentation: https://esbuild.github.io/api/#jsx */
jsx?: 'transform' | 'preserve';
/** Documentation: https://esbuild.github.io/api/#jsx-factory */
jsxFactory?: string;
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */
jsxFragment?: string;
/** Documentation: https://esbuild.github.io/api/#define */
define?: { [key: string]: string };
/** Documentation: https://esbuild.github.io/api/#pure */
pure?: string[];
/** Documentation: https://esbuild.github.io/api/#keep-names */
keepNames?: boolean;
/** Documentation: https://esbuild.github.io/api/#color */
color?: boolean;
/** Documentation: https://esbuild.github.io/api/#log-level */
logLevel?: LogLevel_2;
/** Documentation: https://esbuild.github.io/api/#log-limit */
logLimit?: number;
}
declare interface CompressOptions {
arguments?: boolean;
arrows?: boolean;
booleans_as_integers?: boolean;
booleans?: boolean;
collapse_vars?: boolean;
comparisons?: boolean;
computed_props?: boolean;
conditionals?: boolean;
dead_code?: boolean;
defaults?: boolean;
directives?: boolean;
drop_console?: boolean;
drop_debugger?: boolean;
ecma?: ECMA;
evaluate?: boolean;
expression?: boolean;
global_defs?: object;
hoist_funs?: boolean;
hoist_props?: boolean;
hoist_vars?: boolean;
ie8?: boolean;
if_return?: boolean;
inline?: boolean | InlineFunctions;
join_vars?: boolean;
keep_classnames?: boolean | RegExp;
keep_fargs?: boolean;
keep_fnames?: boolean | RegExp;
keep_infinity?: boolean;
loops?: boolean;
module?: boolean;
negate_iife?: boolean;
passes?: number;
properties?: boolean;
pure_funcs?: string[];
pure_getters?: boolean | 'strict';
reduce_funcs?: boolean;
reduce_vars?: boolean;
sequences?: boolean | number;
side_effects?: boolean;
switches?: boolean;
toplevel?: boolean;
top_retain?: null | string | string[] | RegExp;
typeofs?: boolean;
unsafe_arrows?: boolean;
unsafe?: boolean;
unsafe_comps?: boolean;
unsafe_Function?: boolean;
unsafe_math?: boolean;
unsafe_symbols?: boolean;
unsafe_methods?: boolean;
unsafe_proto?: boolean;
unsafe_regexp?: boolean;
unsafe_undefined?: boolean;
unused?: boolean;
}
declare type CSSOption = {
modules: boolean | string | object;
};
declare type Define = Record;
export declare interface DevServer {
/**
* Dev server host.
*
* @default "localhost"
*/
host?: string;
/**
* Dev server port.
*
* @default 5566
*/
port?: number;
/**
* Automatically open the app in the browser on server start.
*
* @default false
*/
open?: boolean;
/**
* Configure custom proxy rules for the dev server.
*/
proxy?: Record;
/**
* @internal
* If show server log when using custom server
*
* @default true
*/
serverLog?: boolean;
historyApiFallback?: boolean;
}
export declare type DevServerNormalized = Required;
declare type Drop = 'console' | 'debugger';
declare type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
export declare type EsbuildPlugin = Plugin;
declare type External = string[];
export declare type ExtraContext = Record;
declare type FixedSizeArray = T extends 0
? void[]
: ReadonlyArray & {
0: U;
length: T;
};
export declare type Format = 'esm' | 'system' | 'cjs' | 'iife';
declare type Format_2 = 'iife' | 'cjs' | 'esm';
/**
* Converts log messages to formatted message strings suitable for printing in
* the terminal. This allows you to reuse the built-in behavior of esbuild's
* log message formatter. This is a batch-oriented API for efficiency.
*
* - Works in node: yes
* - Works in browser: yes
*/
declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise;
declare interface FormatMessagesOptions {
kind: 'error' | 'warning';
color?: boolean;
terminalWidth?: number;
}
/**
* A synchronous version of "formatMessages".
*
* - Works in node: yes
* - Works in browser: no
*/
declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
declare interface FormatOptions {
ascii_only?: boolean;
/** @deprecated Not implemented anymore */
beautify?: boolean;
braces?: boolean;
comments?: boolean | 'all' | 'some' | RegExp | ( (node: any, comment: {
value: string,
type: 'comment1' | 'comment2' | 'comment3' | 'comment4',
pos: number,
line: number,
col: number,
}) => boolean );
ecma?: ECMA;
ie8?: boolean;
indent_level?: number;
indent_start?: number;
inline_script?: boolean;
keep_quoted_props?: boolean;
max_line_len?: number | false;
preamble?: string;
preserve_annotations?: boolean;
quote_keys?: boolean;
quote_style?: OutputQuoteStyle;
safari10?: boolean;
semicolons?: boolean;
shebang?: boolean;
shorthand?: boolean;
source_map?: SourceMapOptions;
webkit?: boolean;
width?: number;
wrap_iife?: boolean;
wrap_func_args?: boolean;
}
export declare type FramePosition = Omit & {
column?: number;
};
export declare interface FrameRange {
start: FramePosition;
end?: FramePosition;
}
declare type FullTap = Tap & {
type: "sync" | "async" | "promise",
fn: Function
}
declare type Globals = Record;
declare class Hook {
constructor(args?: ArgumentNames>, name?: string);
name: string | undefined;
taps: FullTap[];
intercept(interceptor: HookInterceptor): void;
isUsed(): boolean;
callAsync(...args: Append, Callback_2>): void;
promise(...args: AsArray): Promise;
tap(options: string | Tap & IfSet, fn: (...args: AsArray) => R): void;
withOptions(options: TapOptions & IfSet): Omit;
}
declare interface HookInterceptor {
name?: string;
tap?: (tap: FullTap & IfSet) => void;
call?: (...args: any[]) => void;
loop?: (...args: any[]) => void;
error?: (err: Error) => void;
result?: (result: R) => void;
done?: () => void;
register?: (tap: FullTap & IfSet) => FullTap & IfSet;
}
export declare type Html = HtmlOptions | false;
export declare type HtmlOptions = {
title?: string;
filename?: string;
template?: string;
templateContent?: string;
templateParameters?: object;
favicon?: string;
description?: string;
keywords?: string;
};
export declare interface IBundlerBase {
build(): Promise;
reBuild(paths: string[]): Promise;
close(callack?: Callback): void;
getStats(): WebpackStats;
setStats(stats: WebpackStats): void;
shouldRebuild(paths: string[]): boolean;
}
export declare type ID = number | string;
declare type IfSet = X extends UnsetAdditionalOptions ? {} : X;
export declare abstract class ILogger {
abstract timesLog: Map