/// /// 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; abstract info(...msg: string[]): void; abstract warn(...msg: string[]): void; abstract error(...msg: string[]): void; abstract debug(...msg: string[]): void; abstract time(label: Label): void; abstract timeEnd(label: Label): void; } export declare interface ILoggerOptions { /** * Default is `info`. */ level?: LogLevel; /** * Default is `false`. */ timestamp?: boolean; } declare type ImportKind = | 'entry-point' // JS | 'import-statement' | 'require-call' | 'dynamic-import' | 'require-resolve' // CSS | 'import-rule' | 'url-token' /** * This configures the browser-based version of esbuild. It is necessary to * call this first and wait for the returned promise to be resolved before * making other API calls when using esbuild in the browser. * * - Works in node: yes * - Works in browser: yes ("options" is required) * * Documentation: https://esbuild.github.io/api/#running-in-the-browser */ declare function initialize(options: InitializeOptions): Promise; declare interface InitializeOptions { /** * The URL of the "esbuild.wasm" file. This must be provided when running * esbuild in the browser. */ wasmURL?: string /** * By default esbuild runs the WebAssembly-based browser API in a web worker * to avoid blocking the UI thread. This can be disabled by setting "worker" * to false. */ worker?: boolean } declare enum InlineFunctions { Disabled = 0, SimpleFunctions = 1, WithArguments = 2, WithArgumentsAndVariables = 3 } declare type InnerCallback = (error?: E | null | false, result?: T) => void; /** * Entry points. */ export declare type Input = { [name: string]: string | string[]; }; export declare interface ISourcemapContext { addSourceMap(map?: SourceMap, pluginId?: number): void; getInlineSourceMap(): Promise; getSourceMap(): Promise; } export declare interface ISpeedyBundler { name?: string; parent?: ISpeedyBundler; children: ISpeedyBundler[]; version: string; compilation: IBundlerBase; hooks: ISpeedyBundlerHooks; STAGE: ISpeedyBundlerStage; createChildCompiler(config: CLIConfig, name?: string): Promise; isChild(): boolean; config: BuildConfig; plugins: SpeedyPlugin[]; outputChunk: Map; init(config: CLIConfig): Promise; build(): Promise; close(callBack?: Callback): Promise; emitAsset(name: string, chunk: AssetChunk): void; emitAsset(name: string, chunk: JsChunk): void; emitAsset(name: string, chunk: string): void; watchedFiles: Set; addWatchFile(id: string): void; resolve(source: string, importer: string): Promise; error(message: string, opts: SpeedyErrorOptions): void; getTransformContext(path: string): ITransformContext; getSourcemapContext(path: string): ISourcemapContext; } export declare interface ISpeedyBundlerHooks { /** * Asynchronous initialization. Executed after normalized `buildConfig` and `plugins`. */ initialize: AsyncSeriesHook<[], void>; /** * modify environment variables. */ environment: SyncHook<[]>; /** * compilation stage. */ compilation: AsyncSeriesHook<[]>; /** * Equal to esbuild#onResolve and rollup#resolveId */ resolve: AsyncSeriesBailHook<[ResolveArgs, any], ResolveResult | undefined>; /** * Equal to esbuild#onLoad and rollup#load */ load: AsyncSeriesBailHook<[LoadArgs], LoadResult | undefined | void>; /** * */ transform: AsyncSeriesWaterfallHook; /** * 用于修改编译后的chunk产物 */ processAsset: AsyncSeriesWaterfallHook<[Chunk]>; /** * backend bundler的onStart, watch会触发 */ startCompilation: AsyncSeriesHook<[]>; /** * backend bundler的onEnd, watch会触发 */ endCompilation: AsyncSeriesHook<[]>; /** * 所有assets的后续处理,如根据assets生成html文件 */ processAssets: AsyncSeriesHook<[Map, SpeedyManifest]>; processManifest: AsyncSeriesHook<[SpeedyManifest]>; beforeEmit: AsyncSeriesHook<[]>; transformHTML: AsyncSeriesHook<[ISpeedyBundler]>; done: AsyncSeriesHook<[]>; afterDone: SyncHook; childCompiler: AsyncSeriesHook<[ISpeedyBundler]>; /** * watch related hook */ watchChange: SyncHook<[string, Stats]>; /** * bundler 关闭前触发 */ shutdown: AsyncSeriesHook<[]>; hmr: AsyncSeriesHook<[string[]]>; error: AsyncSeriesHook<[string[]]>; /** * This hook is intended to be used by Speedy Internal Plugins, don't use it publicly or you maybe fired. * @internal * */ esbuild: AsyncSeriesBailHook<[], any>; } export declare interface ISpeedyBundlerStage { /** * Execute Before Internal Plugin */ PRE_INTERNAL: number; /** * Execute After Internal Plugin */ POST_INTERNAL: number; /** * The stage of generate html in processAssets hook. */ PROCESS_ASSETS_GENERATE_HTML: number; /** * The stage of modify generated html in processAssets hook. */ PROCESS_ASSETS_MODIFY_GENERATED_HTML: number; } declare type Item = RegExp | ((path: string) => boolean); export declare interface ITransformContext extends ISourcemapContext { addTransformResult(pluginId: number, result: CacheValue): void; getValidCache(pluginId: number, code: string): undefined | CacheValue; } export declare type JsChunk = { type: 'chunk'; contents: string; fileName: string; originalFileName?: string; map?: SourceMap; entryPoint?: string; modules?: Record; isEntry: boolean; }; declare type Label = string; /** * @internal * @experimental experimental features */ declare type LegalComments = 'none' | 'inline' | 'eof' | 'linked' | 'external'; export declare interface LessOptions { paths: string[]; prependData?: string | prependDataFn; plugins?: any[]; } export declare type LoadArgs = Pick & Pick; declare type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default'; export declare type LoadResult = Pick & { map?: SourceMap; }; declare interface Location { file: string; namespace: string; /** 1-based */ line: number; /** 0-based, in bytes */ column: number; /** in bytes */ length: number; lineText: string; suggestion: string; } declare type Logger = (...args: any[]) => void; /** * Options for log level. */ export declare type LogLevel = 'silent' | 'error' | 'warning' | 'info' | 'debug' | 'verbose'; declare type LogLevel_2 = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'; declare interface LogProvider { log: Logger; debug?: Logger; info?: Logger; warn?: Logger; error?: Logger; } declare type LogProviderCallback = (provider: LogProvider) => LogProvider; declare interface MangleOptions { eval?: boolean; keep_classnames?: boolean | RegExp; keep_fnames?: boolean | RegExp; module?: boolean; nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler; properties?: boolean | ManglePropertiesOptions; reserved?: string[]; safari10?: boolean; toplevel?: boolean; } declare interface ManglePropertiesOptions { builtins?: boolean; debug?: boolean; keep_quoted?: boolean | 'strict'; nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler; regex?: RegExp | string; reserved?: string[]; } declare type Measure = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ? T : never; declare interface Message { pluginName: string; text: string; location: Location | null; notes: Note[]; /** * Optional user-specified data that is passed through unmodified. You can * use this to stash the original error, for example. */ detail: any; } export declare interface Metafile { inputs: { [path: string]: { bytes: number imports: { path: string kind: ImportKind }[] } } outputs: { [path: string]: { bytes: number inputs: { [path: string]: { bytesInOutput: number } } imports: { path: string kind: ImportKind }[] exports: string[] entryPoint?: string } } } /** * Options for minify. */ declare type Minify = 'esbuild' | 'terser' | false; declare interface MinifyOptions { compress?: boolean | CompressOptions; ecma?: ECMA; enclose?: boolean | string; ie8?: boolean; keep_classnames?: boolean | RegExp; keep_fnames?: boolean | RegExp; mangle?: boolean | MangleOptions; module?: boolean; nameCache?: object; format?: FormatOptions; /** @deprecated */ output?: FormatOptions; parse?: ParseOptions; safari10?: boolean; sourceMap?: boolean | SourceMapOptions; toplevel?: boolean; } /** * Different mode has different default args. * For example, in production mode, `minify` is enabled by default. */ export declare type Mode = 'development' | 'production'; export declare interface ModuleReason { moduleId: ID | null; moduleIdentifier: string | null; module: string | null; moduleName: string | null; type: ModuleReasonType; explanation?: string; userRequest: string; loc: string; } export declare type ModuleReasonType = 'amd define' | 'amd require array' | 'amd require context' | 'amd require' | 'cjs require context' | 'cjs require' | 'context element' | 'delegated exports' | 'delegated source' | 'dll entry' | 'accepted harmony modules' | 'harmony accept' | 'harmony export expression' | 'harmony export header' | 'harmony export imported specifier' | 'harmony export specifier' | 'harmony import specifier' | 'harmony side effect evaluation' | 'harmony init' | 'import() context development' | 'import() context production' | 'import() eager' | 'import() weak' | 'import()' | 'json exports' | 'loader' | 'module.hot.accept' | 'module.hot.decline' | 'multi entry' | 'null' | 'prefetch' | 'require.context' | 'require.ensure' | 'require.ensure item' | 'require.include' | 'require.resolve' | 'single entry' | 'wasm export import' | 'wasm import'; declare interface Note { text: string; location: Location | null; } /** 偏移量范围 */ export declare interface OffsetRange { start: number; end: number; } declare interface OnLoadArgs { path: string; namespace: string; suffix: string; pluginData: any; } declare interface OnLoadOptions { filter: RegExp; namespace?: string; } declare interface OnLoadResult { pluginName?: string; errors?: PartialMessage[]; warnings?: PartialMessage[]; contents?: string | Uint8Array; resolveDir?: string; loader?: Loader; pluginData?: any; watchFiles?: string[]; watchDirs?: string[]; } declare interface OnResolveArgs { path: string; importer: string; namespace: string; resolveDir: string; kind: ImportKind; pluginData: any; } declare interface OnResolveOptions { filter: RegExp; namespace?: string; } declare interface OnResolveResult { pluginName?: string; errors?: PartialMessage[]; warnings?: PartialMessage[]; path?: string; external?: boolean; sideEffects?: boolean; namespace?: string; suffix?: string; pluginData?: any; watchFiles?: string[]; watchDirs?: string[]; } declare interface OnStartResult { errors?: PartialMessage[]; warnings?: PartialMessage[]; } declare interface Options extends ServerOptions { pathRewrite?: { [regexp: string]: string; } | ((path: string, req: any) => string) | ((path: string, req: any) => Promise); router?: { [hostOrPath: string]: ServerOptions['target']; } | ((req: any) => ServerOptions['target']) | ((req: any) => Promise); logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent'; logProvider?: LogProviderCallback; onError?: (...args: any[]) => void; onProxyRes?: (...args: any[]) => void; onProxyReq?: (...args: any[]) => void; onProxyReqWs?: (...args: any[]) => void; onOpen?: (...args: any[]) => void; onClose?: (...args: any[]) => void; } /** * Options for output. */ export declare type Output = { /** * The directory for output */ path?: string; publicPath?: string | PublicPathFunction; filename?: string; /** * It's only for internal usage * @internal */ entryNames?: string; chunkNames?: string; format?: Format | ((chunkName: string) => Format); /** * @internal * @experimental code splitting strategy */ splitting?: boolean; clean?: boolean; }; declare interface OutputFile { path: string; /** "text" as bytes */ contents: Uint8Array; /** "contents" as text */ text: string; } export declare type OutputNormalized = { path: string; publicPath: string | PublicPathFunction; filename: string; entryNames?: string; chunkNames?: string; format: Format | ((chunkName: string) => Format); splitting: boolean; clean: boolean; }; declare enum OutputQuoteStyle { PreferDouble = 0, AlwaysSingle = 1, AlwaysDouble = 2, AlwaysOriginal = 3 } declare interface ParseOptions { bare_returns?: boolean; ecma?: ECMA; html5_comments?: boolean; shebang?: boolean; } declare interface PartialMessage { pluginName?: string; text?: string; location?: Partial | null; notes?: PartialNote[]; detail?: any; } declare interface PartialNote { text?: string; location?: Partial | null; } declare type Platform = 'browser' | 'node' | 'neutral'; declare type Platform_2 = 'node' | 'browser'; declare interface Plugin { name: string; setup: (build: PluginBuild) => (void | Promise); } declare interface PluginBuild { initialOptions: BuildOptions; resolve(path: string, options?: ResolveOptions): Promise; onStart(callback: () => (OnStartResult | null | void | Promise)): void; onEnd(callback: (result: BuildResult) => (void | Promise)): void; onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) => (OnResolveResult | null | undefined | Promise)): void; onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) => (OnLoadResult | null | undefined | Promise)): void; // This is a full copy of the esbuild library in case you need it esbuild: { serve: typeof serve, build: typeof build, buildSync: typeof buildSync, transform: typeof transform, transformSync: typeof transformSync, formatMessages: typeof formatMessages, formatMessagesSync: typeof formatMessagesSync, analyzeMetafile: typeof analyzeMetafile, analyzeMetafileSync: typeof analyzeMetafileSync, initialize: typeof initialize, version: typeof version, }; } /** 位置 */ export declare interface Position { line: number; column: number; } export declare interface PostcssOptions { plugins?: any[]; } export declare interface PostCssPx2RemOptions { /** * @default 50 */ rootValue?: number; /** * @default 5 */ unitPrecision?: number; /** * @default ['*'] */ propList?: string[]; selectorBlackList?: string[]; replace?: boolean; mediaQuery?: boolean; minPixelValue?: number; exclude?: string | ((file: string) => boolean) | RegExp; } declare type prependDataFn = (filePath: string) => string; /** * Enable profile plugin. * - `true` means enable cpuProfile. * - `hooks` means enable tapable profile. */ declare type Profile = boolean | 'hooks'; declare type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed; declare interface ProxyTargetDetailed { host: string; port: number; protocol?: string | undefined; hostname?: string | undefined; socketPath?: string | undefined; key?: string | undefined; passphrase?: string | undefined; pfx?: Buffer | string | undefined; cert?: string | undefined; ca?: string | undefined; ciphers?: string | undefined; secureProtocol?: string | undefined; } declare type ProxyTargetUrl = string | Partial; declare type PublicPathFunction = (id: string) => string; /** 位置范围 */ export declare interface Range { start: Position; end: Position; } export declare type Raw = RegExp | ((filePath: string) => boolean); declare interface RawSourceMap { version: number; sources: string[]; names: string[]; sourceRoot?: string; sourcesContent?: string[]; mappings: string; file: string; } /** * Options for the resolver. */ export declare type Resolve = { resolver?: 'native-resolve' | 'enhanced-resolve'; /** * This is only valid for enhanced-resolve */ alias?: Record; mainFields?: string[]; /** * @internal This is only valid for enhanced-resolve */ mainFiles?: string[]; /** * @internal This is only valid for enhanced-resolve */ preferRelative?: boolean; }; export declare type ResolveArgs = Pick; export declare type ResolveNormalized = Required; declare interface ResolveOptions { pluginName?: string; importer?: string; namespace?: string; resolveDir?: string; kind?: ImportKind; pluginData?: any; } export declare type ResolveResult = Pick; declare interface ResolveResult_2 { errors: Message[]; warnings: Message[]; path: string; external: boolean; sideEffects: boolean; namespace: string; suffix: string; pluginData: any; } /** * Only merge additional fields from U to T. */ export declare type SafeMerge = T & { [K in keyof U as Exclude]: U[K]; }; export declare interface SassOptions { prependData?: string | prependDataFn; } /** * This function is similar to "build" but it serves the resulting files over * HTTP on a localhost address with the specified port. * * - Works in node: yes * - Works in browser: no * * Documentation: https://esbuild.github.io/api/#serve */ declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise; declare interface ServeOnRequestArgs { remoteAddress: string; method: string; path: string; status: number; /** The time to generate the response, not to send it */ timeInMS: number; } /** Documentation: https://esbuild.github.io/api/#serve-arguments */ declare interface ServeOptions { port?: number; host?: string; servedir?: string; onRequest?: (args: ServeOnRequestArgs) => void; } /** Documentation: https://esbuild.github.io/api/#serve-return-values */ declare interface ServeResult { port: number; host: string; wait: Promise; stop: () => void; } declare interface ServerOptions { /** URL string to be parsed with the url module. */ target?: ProxyTarget | undefined; /** URL string to be parsed with the url module. */ forward?: ProxyTargetUrl | undefined; /** Object to be passed to http(s).request. */ agent?: any; /** Object to be passed to https.createServer(). */ ssl?: any; /** If you want to proxy websockets. */ ws?: boolean | undefined; /** Adds x- forward headers. */ xfwd?: boolean | undefined; /** Verify SSL certificate. */ secure?: boolean | undefined; /** Explicitly specify if we are proxying to another proxy. */ toProxy?: boolean | undefined; /** Specify whether you want to prepend the target's path to the proxy path. */ prependPath?: boolean | undefined; /** Specify whether you want to ignore the proxy path of the incoming request. */ ignorePath?: boolean | undefined; /** Local interface string to bind for outgoing connections. */ localAddress?: string | undefined; /** Changes the origin of the host header to the target URL. */ changeOrigin?: boolean | undefined; /** specify whether you want to keep letter case of response header key */ preserveHeaderKeyCase?: boolean | undefined; /** Basic authentication i.e. 'user:password' to compute an Authorization header. */ auth?: string | undefined; /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */ hostRewrite?: string | undefined; /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */ autoRewrite?: boolean | undefined; /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */ protocolRewrite?: string | undefined; /** rewrites domain of set-cookie headers. */ cookieDomainRewrite?: false | string | { [oldDomain: string]: string; } | undefined; /** rewrites path of set-cookie headers. Default: false */ cookiePathRewrite?: false | string | { [oldPath: string]: string; } | undefined; /** object with extra headers to be added to target requests. */ headers?: { [header: string]: string; } | undefined; /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */ proxyTimeout?: number | undefined; /** Timeout (in milliseconds) for incoming requests */ timeout?: number | undefined; /** Specify whether you want to follow redirects. Default: false */ followRedirects?: boolean | undefined; /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */ selfHandleResponse?: boolean | undefined; /** Buffer */ buffer?: any; } /** * An identifier mangler for which the output is invariant with respect to the source code. */ declare interface SimpleIdentifierMangler { /** * Obtains the nth most favored (usually shortest) identifier to rename a variable to. * The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word. * This function is expected to be stable; Evaluating get(n) === get(n) should always return true. * @param n The ordinal of the identifier. */ get(n: number): string; } export declare type Source = { code: string; map?: SourceMap; path: string; loader?: string; /** * Whether enable cache. * @default true */ cache?: boolean; }; export declare interface SourceMap { mappings: string; names: string[]; sources: (string | null)[]; version: number; sourcesContent?: (string | null)[]; } /** * The mode of sourcemap */ declare type SourceMap_2 = boolean | 'inline' | 'external'; declare interface SourceMapOptions { /** Source map object, 'inline' or source map file content */ content?: RawSourceMap | string; includeSources?: boolean; filename?: string; root?: string; url?: string | 'inline'; } export declare type SpeedyBundlerConstructor = TConstructor & { create(config: CLIConfig): Promise; }; export declare interface SpeedyErrorOptions { hint?: string; documentationURL?: string; errors?: Error[]; hideStack?: boolean; disableColor?: boolean; codeFrame?: CodeFrameOption; } export declare type SpeedyManifest = { metafile: Metafile; config: BuildOptions; stats: WebpackStats; }; export declare interface SpeedyPlugin { name: string; apply(compiler: SafeMerge): void; } declare interface StdinOptions { contents: string; resolveDir?: string; sourcefile?: string; loader?: Loader; } export declare interface Style { name?: string; test?: RegExp; include?: Item[]; exclude?: Item[]; platform?: string; minify?: boolean; css?: CSSOption; sass?: SassOptions; scss?: SassOptions; less?: any; postcss?: PostcssOptions; } export declare interface SwcFeature { systemjs?: boolean; } declare class SyncHook extends Hook { call(...args: AsArray): R; } export declare type Tag = 'COMMON_ASSET' | 'DYNAMIC_COMPONENT'; declare type Tap = TapOptions & { name: string; }; declare type TapOptions = { before?: string; stage?: number; }; /** * The code version of output. */ declare type Target = 'es6' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'esnext'; declare type TConstructor = new (...args: U) => T; /** * Options for terser, it will enabled when `minify` is `'terser'`. */ declare type TerserMinifyOptions = MinifyOptions; /** * This function transforms a single JavaScript file. It can be used to minify * JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript * to older JavaScript. It returns a promise that is either resolved with a * "TransformResult" object or rejected with a "TransformFailure" object. * * - Works in node: yes * - Works in browser: yes * * Documentation: https://esbuild.github.io/api/#transform-api */ declare function transform(input: string, options?: TransformOptions): Promise; declare interface TransformOptions extends CommonOptions { tsconfigRaw?: string | { compilerOptions?: { jsxFactory?: string, jsxFragmentFactory?: string, useDefineForClassFields?: boolean, importsNotUsedAsValues?: 'remove' | 'preserve' | 'error', preserveValueImports?: boolean, }, }; sourcefile?: string; loader?: Loader; banner?: string; footer?: string; } declare interface TransformResult { code: string; map: string; warnings: Message[]; /** Only when "mangleCache" is present */ mangleCache?: Record; } /** * A synchronous version of "transform". * * - Works in node: yes * - Works in browser: no * * Documentation: https://esbuild.github.io/api/#transform-api */ declare function transformSync(input: string, options?: TransformOptions): TransformResult; declare class UnsetAdditionalOptions { _UnsetAdditionalOptions: true } export declare interface UserConfig { mode?: Mode; input?: Input; output?: Output; profile?: Profile; watch?: Watch; logLevel?: LogLevel; resolve?: Resolve; write?: Write; plugins?: SpeedyPlugin[]; minify?: Minify; terserOptions?: TerserMinifyOptions; target?: Target; sourceMap?: SourceMap_2; globals?: Globals; style?: Style; asset?: Asset; external?: External; dev?: DevServer | false; html?: Html; /** @default "none" */ legalComments?: LegalComments; /** @default { metafile: false, stats: false } */ analyze?: Analyze; /** @default {} */ define?: Define; /** @default "browser" */ platform?: Platform_2; /** @default "webapp" */ preset?: 'webapp' | 'library'; cache?: Cache; experimental?: { swc?: SwcFeature; }; } declare let version: string; /** * When file changed bundler will rebuild under watch mode. */ declare type Watch = boolean; declare interface WatchMode { onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void; } export declare interface WebpackStats { moduleMap?: Map; outputPath?: string; publicPath?: string; hash?: string; version?: string; entrypoints?: Record; assets?: BundleAsset[]; chunks?: BundleChunk[]; } /** * An identifier mangler that leverages character frequency analysis to determine identifier precedence. */ declare interface WeightedIdentifierMangler extends SimpleIdentifierMangler { /** * Modifies the internal weighting of the input characters by the specified delta. * Will be invoked on the entire printed AST, and then deduct mangleable identifiers. * @param chars The characters to modify the weighting of. * @param delta The numeric weight to add to the characters. */ consider(chars: string, delta: number): number; /** * Resets character weights. */ reset(): void; /** * Sorts identifiers by character frequency, in preparation for calls to get(n). */ sort(): void; } /** * Write to disk or not. */ declare type Write = boolean; export { }