| export type Platform = 'browser' | 'node' | 'neutral' |
| export type Format = 'iife' | 'cjs' | 'esm' |
| export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx' |
| export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent' |
| export type Charset = 'ascii' | 'utf8' |
| export type Drop = 'console' | 'debugger' |
|
|
| interface CommonOptions { |
| |
| sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both' |
| |
| legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external' |
| |
| sourceRoot?: string |
| |
| sourcesContent?: boolean |
|
|
| |
| format?: Format |
| |
| globalName?: string |
| |
| target?: string | string[] |
| |
| supported?: Record<string, boolean> |
| |
| platform?: Platform |
|
|
| |
| mangleProps?: RegExp |
| |
| reserveProps?: RegExp |
| |
| mangleQuoted?: boolean |
| |
| mangleCache?: Record<string, string | false> |
| |
| drop?: Drop[] |
| |
| minify?: boolean |
| |
| minifyWhitespace?: boolean |
| |
| minifyIdentifiers?: boolean |
| |
| minifySyntax?: boolean |
| |
| charset?: Charset |
| |
| treeShaking?: boolean |
| |
| ignoreAnnotations?: boolean |
|
|
| |
| jsx?: 'transform' | 'preserve' | 'automatic' |
| |
| jsxFactory?: string |
| |
| jsxFragment?: string |
| |
| jsxImportSource?: string |
| |
| jsxDev?: boolean |
| |
| jsxSideEffects?: boolean |
|
|
| |
| define?: { [key: string]: string } |
| |
| pure?: string[] |
| |
| keepNames?: boolean |
|
|
| |
| color?: boolean |
| |
| logLevel?: LogLevel |
| |
| logLimit?: number |
| |
| logOverride?: Record<string, LogLevel> |
| } |
|
|
| export interface BuildOptions extends CommonOptions { |
| |
| bundle?: boolean |
| |
| splitting?: boolean |
| |
| preserveSymlinks?: boolean |
| |
| outfile?: string |
| |
| metafile?: boolean |
| |
| outdir?: string |
| |
| outbase?: string |
| |
| external?: string[] |
| |
| packages?: 'external' |
| |
| alias?: Record<string, string> |
| |
| loader?: { [ext: string]: Loader } |
| |
| resolveExtensions?: string[] |
| |
| mainFields?: string[] |
| |
| conditions?: string[] |
| |
| write?: boolean |
| |
| allowOverwrite?: boolean |
| |
| tsconfig?: string |
| |
| outExtension?: { [ext: string]: string } |
| |
| publicPath?: string |
| |
| entryNames?: string |
| |
| chunkNames?: string |
| |
| assetNames?: string |
| |
| inject?: string[] |
| |
| banner?: { [type: string]: string } |
| |
| footer?: { [type: string]: string } |
| |
| entryPoints?: string[] | Record<string, string> | { in: string, out: string }[] |
| |
| stdin?: StdinOptions |
| |
| plugins?: Plugin[] |
| |
| absWorkingDir?: string |
| |
| nodePaths?: string[]; |
| } |
|
|
| export interface StdinOptions { |
| contents: string | Uint8Array |
| resolveDir?: string |
| sourcefile?: string |
| loader?: Loader |
| } |
|
|
| export interface Message { |
| id: string |
| pluginName: string |
| text: string |
| location: Location | null |
| notes: Note[] |
|
|
| |
| |
| |
| |
| detail: any |
| } |
|
|
| export interface Note { |
| text: string |
| location: Location | null |
| } |
|
|
| export interface Location { |
| file: string |
| namespace: string |
| |
| line: number |
| |
| column: number |
| |
| length: number |
| lineText: string |
| suggestion: string |
| } |
|
|
| export interface OutputFile { |
| path: string |
| |
| contents: Uint8Array |
| |
| readonly text: string |
| } |
|
|
| export interface BuildResult<SpecificOptions extends BuildOptions = BuildOptions> { |
| errors: Message[] |
| warnings: Message[] |
| |
| outputFiles: OutputFile[] | (SpecificOptions['write'] extends false ? never : undefined) |
| |
| metafile: Metafile | (SpecificOptions['metafile'] extends true ? never : undefined) |
| |
| mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined) |
| } |
|
|
| export interface BuildFailure extends Error { |
| errors: Message[] |
| warnings: Message[] |
| } |
|
|
| |
| export interface ServeOptions { |
| port?: number |
| host?: string |
| servedir?: string |
| keyfile?: string |
| certfile?: string |
| onRequest?: (args: ServeOnRequestArgs) => void |
| } |
|
|
| export interface ServeOnRequestArgs { |
| remoteAddress: string |
| method: string |
| path: string |
| status: number |
| |
| timeInMS: number |
| } |
|
|
| |
| export interface ServeResult { |
| port: number |
| host: string |
| } |
|
|
| export interface TransformOptions extends CommonOptions { |
| tsconfigRaw?: string | { |
| compilerOptions?: { |
| alwaysStrict?: boolean, |
| importsNotUsedAsValues?: 'remove' | 'preserve' | 'error', |
| jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve', |
| jsxFactory?: string, |
| jsxFragmentFactory?: string, |
| jsxImportSource?: string, |
| preserveValueImports?: boolean, |
| target?: string, |
| useDefineForClassFields?: boolean, |
| }, |
| } |
|
|
| sourcefile?: string |
| loader?: Loader |
| banner?: string |
| footer?: string |
| } |
|
|
| export interface TransformResult<SpecificOptions extends TransformOptions = TransformOptions> { |
| code: string |
| map: string |
| warnings: Message[] |
| |
| mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined) |
| |
| legalComments: string | (SpecificOptions['legalComments'] extends 'external' ? never : undefined) |
| } |
|
|
| export interface TransformFailure extends Error { |
| errors: Message[] |
| warnings: Message[] |
| } |
|
|
| export interface Plugin { |
| name: string |
| setup: (build: PluginBuild) => (void | Promise<void>) |
| } |
|
|
| export interface PluginBuild { |
| |
| initialOptions: BuildOptions |
|
|
| |
| resolve(path: string, options?: ResolveOptions): Promise<ResolveResult> |
|
|
| |
| onStart(callback: () => |
| (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void |
|
|
| |
| onEnd(callback: (result: BuildResult) => |
| (OnEndResult | null | void | Promise<OnEndResult | null | void>)): void |
|
|
| |
| onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) => |
| (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void |
|
|
| |
| onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) => |
| (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void |
|
|
| |
| onDispose(callback: () => void): void |
|
|
| |
| esbuild: { |
| context: typeof context, |
| 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 interface ResolveOptions { |
| pluginName?: string |
| importer?: string |
| namespace?: string |
| resolveDir?: string |
| kind?: ImportKind |
| pluginData?: any |
| } |
|
|
| /** Documentation: https://esbuild.github.io/plugins/#resolve-results */ |
| export interface ResolveResult { |
| errors: Message[] |
| warnings: Message[] |
|
|
| path: string |
| external: boolean |
| sideEffects: boolean |
| namespace: string |
| suffix: string |
| pluginData: any |
| } |
|
|
| export interface OnStartResult { |
| errors?: PartialMessage[] |
| warnings?: PartialMessage[] |
| } |
|
|
| export interface OnEndResult { |
| errors?: PartialMessage[] |
| warnings?: PartialMessage[] |
| } |
|
|
| |
| export interface OnResolveOptions { |
| filter: RegExp |
| namespace?: string |
| } |
|
|
| /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */ |
| export interface OnResolveArgs { |
| path: string |
| importer: string |
| namespace: string |
| resolveDir: string |
| kind: ImportKind |
| pluginData: any |
| } |
|
|
| export type ImportKind = |
| | 'entry-point' |
|
|
| |
| | 'import-statement' |
| | 'require-call' |
| | 'dynamic-import' |
| | 'require-resolve' |
|
|
| |
| | 'import-rule' |
| | 'url-token' |
|
|
| |
| export interface OnResolveResult { |
| pluginName?: string |
|
|
| errors?: PartialMessage[] |
| warnings?: PartialMessage[] |
|
|
| path?: string |
| external?: boolean |
| sideEffects?: boolean |
| namespace?: string |
| suffix?: string |
| pluginData?: any |
|
|
| watchFiles?: string[] |
| watchDirs?: string[] |
| } |
|
|
| /** Documentation: https://esbuild.github.io/plugins/#on-load-options */ |
| export interface OnLoadOptions { |
| filter: RegExp |
| namespace?: string |
| } |
|
|
| /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */ |
| export interface OnLoadArgs { |
| path: string |
| namespace: string |
| suffix: string |
| pluginData: any |
| } |
|
|
| |
| export interface OnLoadResult { |
| pluginName?: string |
|
|
| errors?: PartialMessage[] |
| warnings?: PartialMessage[] |
|
|
| contents?: string | Uint8Array |
| resolveDir?: string |
| loader?: Loader |
| pluginData?: any |
|
|
| watchFiles?: string[] |
| watchDirs?: string[] |
| } |
|
|
| export interface PartialMessage { |
| id?: string |
| pluginName?: string |
| text?: string |
| location?: Partial<Location> | null |
| notes?: PartialNote[] |
| detail?: any |
| } |
|
|
| export interface PartialNote { |
| text?: string |
| location?: Partial<Location> | null |
| } |
|
|
| |
| export interface Metafile { |
| inputs: { |
| [path: string]: { |
| bytes: number |
| imports: { |
| path: string |
| kind: ImportKind |
| external?: boolean |
| original?: string |
| }[] |
| format?: 'cjs' | 'esm' |
| } |
| } |
| outputs: { |
| [path: string]: { |
| bytes: number |
| inputs: { |
| [path: string]: { |
| bytesInOutput: number |
| } |
| } |
| imports: { |
| path: string |
| kind: ImportKind | 'file-loader' |
| external?: boolean |
| }[] |
| exports: string[] |
| entryPoint?: string |
| cssBundle?: string |
| } |
| } |
| } |
|
|
| export interface FormatMessagesOptions { |
| kind: 'error' | 'warning' |
| color?: boolean |
| terminalWidth?: number |
| } |
|
|
| export interface AnalyzeMetafileOptions { |
| color?: boolean |
| verbose?: boolean |
| } |
|
|
| export interface WatchOptions { |
| } |
|
|
| export interface BuildContext<SpecificOptions extends BuildOptions = BuildOptions> { |
| |
| rebuild(): Promise<BuildResult<SpecificOptions>> |
|
|
| |
| watch(options?: WatchOptions): Promise<void> |
|
|
| |
| serve(options?: ServeOptions): Promise<ServeResult> |
|
|
| cancel(): Promise<void> |
| dispose(): Promise<void> |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function build<SpecificOptions extends BuildOptions>(options: SpecificOptions): Promise<BuildResult<SpecificOptions>> |
| export declare function build(options: BuildOptions): Promise<BuildResult> |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function context<T extends BuildOptions>(options: T): Promise<BuildContext<T>> |
| export declare function context(options: BuildOptions): Promise<BuildContext> |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>> |
| export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult> |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]> |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string> |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function buildSync<SpecificOptions extends BuildOptions>(options: SpecificOptions): BuildResult<SpecificOptions> |
| export declare function buildSync(options: BuildOptions): BuildResult |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function transformSync<SpecificOptions extends TransformOptions>(input: string, options?: SpecificOptions): TransformResult<SpecificOptions> |
| export declare function transformSync(input: string | Uint8Array, options?: TransformOptions): TransformResult |
|
|
| |
| |
| |
| |
| |
| |
| export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[] |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| export declare function initialize(options: InitializeOptions): Promise<void> |
|
|
| export interface InitializeOptions { |
| |
| |
| |
| |
| wasmURL?: string | URL |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| wasmModule?: WebAssembly.Module |
|
|
| |
| |
| |
| |
| |
| worker?: boolean |
| } |
|
|
| export let version: string |
|
|