Skip to main content

esbuild

Interfaces

AnalyzeMetafileOptions

Properties

PropertyType

color?

boolean

verbose?

boolean


BuildContext<ProvidedOptions>

Type Parameters

Type ParameterDefault type

ProvidedOptions extends BuildOptions

BuildOptions

Methods

cancel()

cancel(): Promise<void>

Returns

Promise<void>

dispose()

dispose(): Promise<void>

Returns

Promise<void>

rebuild()

rebuild(): Promise<BuildResult<ProvidedOptions>>

Documentation: https://esbuild.github.io/api/#rebuild

Returns

Promise<BuildResult<ProvidedOptions>>

serve()

serve(options?): Promise<ServeResult>

Documentation: https://esbuild.github.io/api/#serve

Parameters
ParameterType

options?

ServeOptions

Returns

Promise<ServeResult>

watch()

watch(options?): Promise<void>

Documentation: https://esbuild.github.io/api/#watch

Parameters
ParameterType

options?

WatchOptions

Returns

Promise<void>


BuildFailure

Extends

  • Error

Properties

PropertyTypeInherited from

errors

Message[]

message

string

Error.message

name

string

Error.name

warnings

Message[]

cause?

unknown

Error.cause

stack?

string

Error.stack


BuildOptions

Extends

Properties

PropertyTypeDescriptionInherited from

absWorkingDir?

string

Documentation: https://esbuild.github.io/api/#working-directory

alias?

Record<string, string>

Documentation: https://esbuild.github.io/api/#alias

allowOverwrite?

boolean

Documentation: https://esbuild.github.io/api/#allow-overwrite

assetNames?

string

Documentation: https://esbuild.github.io/api/#asset-names

banner?

object

Documentation: https://esbuild.github.io/api/#banner

bundle?

boolean

Documentation: https://esbuild.github.io/api/#bundle

charset?

Charset

Documentation: https://esbuild.github.io/api/#charset

CommonOptions.charset

chunkNames?

string

Documentation: https://esbuild.github.io/api/#chunk-names

color?

boolean

Documentation: https://esbuild.github.io/api/#color

CommonOptions.color

conditions?

string[]

Documentation: https://esbuild.github.io/api/#conditions

define?

object

Documentation: https://esbuild.github.io/api/#define

CommonOptions.define

drop?

Drop[]

Documentation: https://esbuild.github.io/api/#drop

CommonOptions.drop

dropLabels?

string[]

Documentation: https://esbuild.github.io/api/#drop-labels

CommonOptions.dropLabels

entryNames?

string

Documentation: https://esbuild.github.io/api/#entry-names

entryPoints?

string[] | Record<string, string> | object[]

Documentation: https://esbuild.github.io/api/#entry-points

external?

string[]

Documentation: https://esbuild.github.io/api/#external

footer?

object

Documentation: https://esbuild.github.io/api/#footer

format?

Format

Documentation: https://esbuild.github.io/api/#format

CommonOptions.format

globalName?

string

Documentation: https://esbuild.github.io/api/#global-name

CommonOptions.globalName

ignoreAnnotations?

boolean

Documentation: https://esbuild.github.io/api/#ignore-annotations

CommonOptions.ignoreAnnotations

inject?

string[]

Documentation: https://esbuild.github.io/api/#inject

jsx?

"transform" | "preserve" | "automatic"

Documentation: https://esbuild.github.io/api/#jsx

CommonOptions.jsx

jsxDev?

boolean

Documentation: https://esbuild.github.io/api/#jsx-development

CommonOptions.jsxDev

jsxFactory?

string

Documentation: https://esbuild.github.io/api/#jsx-factory

CommonOptions.jsxFactory

jsxFragment?

string

Documentation: https://esbuild.github.io/api/#jsx-fragment

CommonOptions.jsxFragment

jsxImportSource?

string

Documentation: https://esbuild.github.io/api/#jsx-import-source

CommonOptions.jsxImportSource

jsxSideEffects?

boolean

Documentation: https://esbuild.github.io/api/#jsx-side-effects

CommonOptions.jsxSideEffects

keepNames?

boolean

Documentation: https://esbuild.github.io/api/#keep-names

CommonOptions.keepNames

legalComments?

"external" | "linked" | "inline" | "none" | "eof"

Documentation: https://esbuild.github.io/api/#legal-comments

CommonOptions.legalComments

lineLimit?

number

Documentation: https://esbuild.github.io/api/#line-limit

CommonOptions.lineLimit

loader?

object

Documentation: https://esbuild.github.io/api/#loader

logLevel?

LogLevel

Documentation: https://esbuild.github.io/api/#log-level

CommonOptions.logLevel

logLimit?

number

Documentation: https://esbuild.github.io/api/#log-limit

CommonOptions.logLimit

logOverride?

Record<string, LogLevel>

Documentation: https://esbuild.github.io/api/#log-override

CommonOptions.logOverride

mainFields?

string[]

Documentation: https://esbuild.github.io/api/#main-fields

mangleCache?

Record<string, string | false>

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.mangleCache

mangleProps?

RegExp

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.mangleProps

mangleQuoted?

boolean

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.mangleQuoted

metafile?

boolean

Documentation: https://esbuild.github.io/api/#metafile

minify?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minify

minifyIdentifiers?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minifyIdentifiers

minifySyntax?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minifySyntax

minifyWhitespace?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minifyWhitespace

nodePaths?

string[]

Documentation: https://esbuild.github.io/api/#node-paths

outbase?

string

Documentation: https://esbuild.github.io/api/#outbase

outdir?

string

Documentation: https://esbuild.github.io/api/#outdir

outExtension?

object

Documentation: https://esbuild.github.io/api/#out-extension

outfile?

string

Documentation: https://esbuild.github.io/api/#outfile

packages?

"bundle" | "external"

Documentation: https://esbuild.github.io/api/#packages

platform?

Platform

Documentation: https://esbuild.github.io/api/#platform

CommonOptions.platform

plugins?

Plugin[]

Documentation: https://esbuild.github.io/plugins/

preserveSymlinks?

boolean

Documentation: https://esbuild.github.io/api/#preserve-symlinks

publicPath?

string

Documentation: https://esbuild.github.io/api/#public-path

pure?

string[]

Documentation: https://esbuild.github.io/api/#pure

CommonOptions.pure

reserveProps?

RegExp

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.reserveProps

resolveExtensions?

string[]

Documentation: https://esbuild.github.io/api/#resolve-extensions

sourcemap?

boolean | "external" | "linked" | "inline" | "both"

Documentation: https://esbuild.github.io/api/#sourcemap

CommonOptions.sourcemap

sourceRoot?

string

Documentation: https://esbuild.github.io/api/#source-root

CommonOptions.sourceRoot

sourcesContent?

boolean

Documentation: https://esbuild.github.io/api/#sources-content

CommonOptions.sourcesContent

splitting?

boolean

Documentation: https://esbuild.github.io/api/#splitting

stdin?

StdinOptions

Documentation: https://esbuild.github.io/api/#stdin

supported?

Record<string, boolean>

Documentation: https://esbuild.github.io/api/#supported

CommonOptions.supported

target?

string | string[]

Documentation: https://esbuild.github.io/api/#target

CommonOptions.target

treeShaking?

boolean

Documentation: https://esbuild.github.io/api/#tree-shaking

CommonOptions.treeShaking

tsconfig?

string

Documentation: https://esbuild.github.io/api/#tsconfig

tsconfigRaw?

string | TsconfigRaw

Documentation: https://esbuild.github.io/api/#tsconfig-raw

CommonOptions.tsconfigRaw

write?

boolean

Documentation: https://esbuild.github.io/api/#write


BuildResult<ProvidedOptions>

Type Parameters

Type ParameterDefault type

ProvidedOptions extends BuildOptions

BuildOptions

Properties

PropertyTypeDescription

errors

Message[]

mangleCache

Record<string, string | false> | ProvidedOptions["mangleCache"] extends Object ? never : undefined

Only when "mangleCache" is present

metafile

Metafile | ProvidedOptions["metafile"] extends true ? never : undefined

Only when "metafile: true"

outputFiles

OutputFile[] | ProvidedOptions["write"] extends false ? never : undefined

Only when "write: false"

warnings

Message[]


CommonOptions

Extended by

Properties

PropertyTypeDescription

charset?

Charset

Documentation: https://esbuild.github.io/api/#charset

color?

boolean

Documentation: https://esbuild.github.io/api/#color

define?

object

Documentation: https://esbuild.github.io/api/#define

drop?

Drop[]

Documentation: https://esbuild.github.io/api/#drop

dropLabels?

string[]

Documentation: https://esbuild.github.io/api/#drop-labels

format?

Format

Documentation: https://esbuild.github.io/api/#format

globalName?

string

Documentation: https://esbuild.github.io/api/#global-name

ignoreAnnotations?

boolean

Documentation: https://esbuild.github.io/api/#ignore-annotations

jsx?

"transform" | "preserve" | "automatic"

Documentation: https://esbuild.github.io/api/#jsx

jsxDev?

boolean

Documentation: https://esbuild.github.io/api/#jsx-development

jsxFactory?

string

Documentation: https://esbuild.github.io/api/#jsx-factory

jsxFragment?

string

Documentation: https://esbuild.github.io/api/#jsx-fragment

jsxImportSource?

string

Documentation: https://esbuild.github.io/api/#jsx-import-source

jsxSideEffects?

boolean

Documentation: https://esbuild.github.io/api/#jsx-side-effects

keepNames?

boolean

Documentation: https://esbuild.github.io/api/#keep-names

legalComments?

"external" | "linked" | "inline" | "none" | "eof"

Documentation: https://esbuild.github.io/api/#legal-comments

lineLimit?

number

Documentation: https://esbuild.github.io/api/#line-limit

logLevel?

LogLevel

Documentation: https://esbuild.github.io/api/#log-level

logLimit?

number

Documentation: https://esbuild.github.io/api/#log-limit

logOverride?

Record<string, LogLevel>

Documentation: https://esbuild.github.io/api/#log-override

mangleCache?

Record<string, string | false>

Documentation: https://esbuild.github.io/api/#mangle-props

mangleProps?

RegExp

Documentation: https://esbuild.github.io/api/#mangle-props

mangleQuoted?

boolean

Documentation: https://esbuild.github.io/api/#mangle-props

minify?

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/#minify

minifyWhitespace?

boolean

Documentation: https://esbuild.github.io/api/#minify

platform?

Platform

Documentation: https://esbuild.github.io/api/#platform

pure?

string[]

Documentation: https://esbuild.github.io/api/#pure

reserveProps?

RegExp

Documentation: https://esbuild.github.io/api/#mangle-props

sourcemap?

boolean | "external" | "linked" | "inline" | "both"

Documentation: https://esbuild.github.io/api/#sourcemap

sourceRoot?

string

Documentation: https://esbuild.github.io/api/#source-root

sourcesContent?

boolean

Documentation: https://esbuild.github.io/api/#sources-content

supported?

Record<string, boolean>

Documentation: https://esbuild.github.io/api/#supported

target?

string | string[]

Documentation: https://esbuild.github.io/api/#target

treeShaking?

boolean

Documentation: https://esbuild.github.io/api/#tree-shaking

tsconfigRaw?

string | TsconfigRaw

Documentation: https://esbuild.github.io/api/#tsconfig-raw


FormatMessagesOptions

Properties

PropertyType

kind

"warning" | "error"

color?

boolean

terminalWidth?

number


InitializeOptions

Properties

PropertyTypeDescription

wasmModule?

Module

The result of calling "new WebAssembly.Module(buffer)" where "buffer" is a typed array or ArrayBuffer containing the binary code of the "esbuild.wasm" file.

You can use this as an alternative to "wasmURL" for environments where it's not possible to download the WebAssembly module.

wasmURL?

string | URL

The URL of the "esbuild.wasm" file. This must be provided when running esbuild in the browser.

worker?

boolean

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.


Location

Properties

PropertyTypeDescription

column

number

0-based, in bytes

file

string

length

number

in bytes

line

number

1-based

lineText

string

namespace

string

suggestion

string


Message

Properties

PropertyTypeDescription

detail

any

Optional user-specified data that is passed through unmodified. You can use this to stash the original error, for example.

id

string

location

null | Location

notes

Note[]

pluginName

string

text

string


Metafile

Documentation: https://esbuild.github.io/api/#metafile

Properties

PropertyType

inputs

object

outputs

object


Note

Properties

PropertyType

location

null | Location

text

string


OnEndResult

Properties

PropertyType

errors?

PartialMessage[]

warnings?

PartialMessage[]


OnLoadArgs

Documentation: https://esbuild.github.io/plugins/#on-load-arguments

Properties

PropertyType

namespace

string

path

string

pluginData

any

suffix

string

with

Record<string, string>


OnLoadOptions

Documentation: https://esbuild.github.io/plugins/#on-load-options

Properties

PropertyType

filter

RegExp

namespace?

string


OnLoadResult

Documentation: https://esbuild.github.io/plugins/#on-load-results

Properties

PropertyType

contents?

string | Uint8Array<ArrayBufferLike>

errors?

PartialMessage[]

loader?

Loader

pluginData?

any

pluginName?

string

resolveDir?

string

warnings?

PartialMessage[]

watchDirs?

string[]

watchFiles?

string[]


OnResolveArgs

Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments

Properties

PropertyType

importer

string

kind

ImportKind

namespace

string

path

string

pluginData

any

resolveDir

string

with

Record<string, string>


OnResolveOptions

Documentation: https://esbuild.github.io/plugins/#on-resolve-options

Properties

PropertyType

filter

RegExp

namespace?

string


OnResolveResult

Documentation: https://esbuild.github.io/plugins/#on-resolve-results

Properties

PropertyType

errors?

PartialMessage[]

external?

boolean

namespace?

string

path?

string

pluginData?

any

pluginName?

string

sideEffects?

boolean

suffix?

string

warnings?

PartialMessage[]

watchDirs?

string[]

watchFiles?

string[]


OnStartResult

Properties

PropertyType

errors?

PartialMessage[]

warnings?

PartialMessage[]


OutputFile

Properties

PropertyModifierTypeDescription

contents

public

Uint8Array<ArrayBufferLike>

hash

public

string

path

public

string

text

readonly

string

"contents" as text (changes automatically with "contents")


PartialMessage

Properties

PropertyType

detail?

any

id?

string

location?

null | Partial<Location>

notes?

PartialNote[]

pluginName?

string

text?

string


PartialNote

Properties

PropertyType

location?

null | Partial<Location>

text?

string


Plugin

Properties

PropertyType

name

string

setup

(build: PluginBuild) => void | Promise<void>


PluginBuild

Properties

PropertyTypeDescription

esbuild

object

esbuild.analyzeMetafile

(metafile: string | Metafile, options?: AnalyzeMetafileOptions) => Promise<string>

esbuild.analyzeMetafileSync

(metafile: string | Metafile, options?: AnalyzeMetafileOptions) => string

esbuild.build

<T>(options: SameShape<BuildOptions, T>) => Promise<BuildResult<T>>

esbuild.buildSync

<T>(options: SameShape<BuildOptions, T>) => BuildResult<T>

esbuild.context

<T>(options: SameShape<BuildOptions, T>) => Promise<BuildContext<T>>

esbuild.formatMessages

(messages: PartialMessage[], options: FormatMessagesOptions) => Promise<string[]>

esbuild.formatMessagesSync

(messages: PartialMessage[], options: FormatMessagesOptions) => string[]

esbuild.initialize

(options: InitializeOptions) => Promise<void>

esbuild.transform

<T>(input: string | Uint8Array<ArrayBufferLike>, options?: SameShape<TransformOptions, T>) => Promise<TransformResult<T>>

esbuild.transformSync

<T>(input: string | Uint8Array<ArrayBufferLike>, options?: SameShape<TransformOptions, T>) => TransformResult<T>

esbuild.version

string

initialOptions

BuildOptions

Documentation: https://esbuild.github.io/plugins/#build-options

Methods

onDispose()

onDispose(callback): void

Documentation: https://esbuild.github.io/plugins/#on-dispose

Parameters
ParameterType

callback

() => void

Returns

void

onEnd()

onEnd(callback): void

Documentation: https://esbuild.github.io/plugins/#on-end

Parameters
ParameterType

callback

(result) => null | void | OnEndResult | Promise<null | void | OnEndResult>

Returns

void

onLoad()

onLoad(options, callback): void

Documentation: https://esbuild.github.io/plugins/#on-load

Parameters
ParameterType

options

OnLoadOptions

callback

(args) => undefined | null | OnLoadResult | Promise<undefined | null | OnLoadResult>

Returns

void

onResolve()

onResolve(options, callback): void

Documentation: https://esbuild.github.io/plugins/#on-resolve

Parameters
ParameterType

options

OnResolveOptions

callback

(args) => undefined | null | OnResolveResult | Promise<undefined | null | OnResolveResult>

Returns

void

onStart()

onStart(callback): void

Documentation: https://esbuild.github.io/plugins/#on-start

Parameters
ParameterType

callback

() => null | void | OnStartResult | Promise<null | void | OnStartResult>

Returns

void

resolve()

resolve(path, options?): Promise<ResolveResult>

Documentation: https://esbuild.github.io/plugins/#resolve

Parameters
ParameterType

path

string

options?

ResolveOptions

Returns

Promise<ResolveResult>


ResolveOptions

Documentation: https://esbuild.github.io/plugins/#resolve-options

Properties

PropertyType

importer?

string

kind?

ImportKind

namespace?

string

pluginData?

any

pluginName?

string

resolveDir?

string

with?

Record<string, string>


ResolveResult

Documentation: https://esbuild.github.io/plugins/#resolve-results

Properties

PropertyType

errors

Message[]

external

boolean

namespace

string

path

string

pluginData

any

sideEffects

boolean

suffix

string

warnings

Message[]


ServeOnRequestArgs

Properties

PropertyTypeDescription

method

string

path

string

remoteAddress

string

status

number

timeInMS

number

The time to generate the response, not to send it


ServeOptions

Documentation: https://esbuild.github.io/api/#serve-arguments

Properties

PropertyType

certfile?

string

fallback?

string

host?

string

keyfile?

string

onRequest?

(args: ServeOnRequestArgs) => void

port?

number

servedir?

string


ServeResult

Documentation: https://esbuild.github.io/api/#serve-return-values

Properties

PropertyType

host

string

port

number


StdinOptions

Properties

PropertyType

contents

string | Uint8Array<ArrayBufferLike>

loader?

Loader

resolveDir?

string

sourcefile?

string


TransformFailure

Extends

  • Error

Properties

PropertyTypeInherited from

errors

Message[]

message

string

Error.message

name

string

Error.name

warnings

Message[]

cause?

unknown

Error.cause

stack?

string

Error.stack


TransformOptions

Extends

Properties

PropertyTypeDescriptionInherited from

banner?

string

Documentation: https://esbuild.github.io/api/#banner

charset?

Charset

Documentation: https://esbuild.github.io/api/#charset

CommonOptions.charset

color?

boolean

Documentation: https://esbuild.github.io/api/#color

CommonOptions.color

define?

object

Documentation: https://esbuild.github.io/api/#define

CommonOptions.define

drop?

Drop[]

Documentation: https://esbuild.github.io/api/#drop

CommonOptions.drop

dropLabels?

string[]

Documentation: https://esbuild.github.io/api/#drop-labels

CommonOptions.dropLabels

footer?

string

Documentation: https://esbuild.github.io/api/#footer

format?

Format

Documentation: https://esbuild.github.io/api/#format

CommonOptions.format

globalName?

string

Documentation: https://esbuild.github.io/api/#global-name

CommonOptions.globalName

ignoreAnnotations?

boolean

Documentation: https://esbuild.github.io/api/#ignore-annotations

CommonOptions.ignoreAnnotations

jsx?

"transform" | "preserve" | "automatic"

Documentation: https://esbuild.github.io/api/#jsx

CommonOptions.jsx

jsxDev?

boolean

Documentation: https://esbuild.github.io/api/#jsx-development

CommonOptions.jsxDev

jsxFactory?

string

Documentation: https://esbuild.github.io/api/#jsx-factory

CommonOptions.jsxFactory

jsxFragment?

string

Documentation: https://esbuild.github.io/api/#jsx-fragment

CommonOptions.jsxFragment

jsxImportSource?

string

Documentation: https://esbuild.github.io/api/#jsx-import-source

CommonOptions.jsxImportSource

jsxSideEffects?

boolean

Documentation: https://esbuild.github.io/api/#jsx-side-effects

CommonOptions.jsxSideEffects

keepNames?

boolean

Documentation: https://esbuild.github.io/api/#keep-names

CommonOptions.keepNames

legalComments?

"external" | "linked" | "inline" | "none" | "eof"

Documentation: https://esbuild.github.io/api/#legal-comments

CommonOptions.legalComments

lineLimit?

number

Documentation: https://esbuild.github.io/api/#line-limit

CommonOptions.lineLimit

loader?

Loader

Documentation: https://esbuild.github.io/api/#loader

logLevel?

LogLevel

Documentation: https://esbuild.github.io/api/#log-level

CommonOptions.logLevel

logLimit?

number

Documentation: https://esbuild.github.io/api/#log-limit

CommonOptions.logLimit

logOverride?

Record<string, LogLevel>

Documentation: https://esbuild.github.io/api/#log-override

CommonOptions.logOverride

mangleCache?

Record<string, string | false>

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.mangleCache

mangleProps?

RegExp

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.mangleProps

mangleQuoted?

boolean

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.mangleQuoted

minify?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minify

minifyIdentifiers?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minifyIdentifiers

minifySyntax?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minifySyntax

minifyWhitespace?

boolean

Documentation: https://esbuild.github.io/api/#minify

CommonOptions.minifyWhitespace

platform?

Platform

Documentation: https://esbuild.github.io/api/#platform

CommonOptions.platform

pure?

string[]

Documentation: https://esbuild.github.io/api/#pure

CommonOptions.pure

reserveProps?

RegExp

Documentation: https://esbuild.github.io/api/#mangle-props

CommonOptions.reserveProps

sourcefile?

string

Documentation: https://esbuild.github.io/api/#sourcefile

sourcemap?

boolean | "external" | "linked" | "inline" | "both"

Documentation: https://esbuild.github.io/api/#sourcemap

CommonOptions.sourcemap

sourceRoot?

string

Documentation: https://esbuild.github.io/api/#source-root

CommonOptions.sourceRoot

sourcesContent?

boolean

Documentation: https://esbuild.github.io/api/#sources-content

CommonOptions.sourcesContent

supported?

Record<string, boolean>

Documentation: https://esbuild.github.io/api/#supported

CommonOptions.supported

target?

string | string[]

Documentation: https://esbuild.github.io/api/#target

CommonOptions.target

treeShaking?

boolean

Documentation: https://esbuild.github.io/api/#tree-shaking

CommonOptions.treeShaking

tsconfigRaw?

string | TsconfigRaw

Documentation: https://esbuild.github.io/api/#tsconfig-raw

CommonOptions.tsconfigRaw


TransformResult<ProvidedOptions>

Type Parameters

Type ParameterDefault type

ProvidedOptions extends TransformOptions

TransformOptions

Properties

PropertyTypeDescription

code

string

legalComments

string | ProvidedOptions["legalComments"] extends "external" ? never : undefined

Only when "legalComments" is "external"

mangleCache

Record<string, string | false> | ProvidedOptions["mangleCache"] extends Object ? never : undefined

Only when "mangleCache" is present

map

string

warnings

Message[]


TsconfigRaw

Properties

PropertyType

compilerOptions?

object

compilerOptions.alwaysStrict?

boolean

compilerOptions.baseUrl?

string

compilerOptions.experimentalDecorators?

boolean

compilerOptions.importsNotUsedAsValues?

"error" | "preserve" | "remove"

compilerOptions.jsx?

"preserve" | "react-native" | "react" | "react-jsx" | "react-jsxdev"

compilerOptions.jsxFactory?

string

compilerOptions.jsxFragmentFactory?

string

compilerOptions.jsxImportSource?

string

compilerOptions.paths?

Record<string, string[]>

compilerOptions.preserveValueImports?

boolean

compilerOptions.strict?

boolean

compilerOptions.target?

string

compilerOptions.useDefineForClassFields?

boolean

compilerOptions.verbatimModuleSyntax?

boolean


WatchOptions

Type Aliases

Charset

Charset: "ascii" | "utf8"


Drop

Drop: "console" | "debugger"


Format

Format: "iife" | "cjs" | "esm"


ImportKind

ImportKind: "entry-point" | "import-statement" | "require-call" | "dynamic-import" | "require-resolve" | "import-rule" | "composes-from" | "url-token"


Loader

Loader: "base64" | "binary" | "copy" | "css" | "dataurl" | "default" | "empty" | "file" | "js" | "json" | "jsx" | "local-css" | "text" | "ts" | "tsx"


LogLevel

LogLevel: "verbose" | "debug" | "info" | "warning" | "error" | "silent"


Platform

Platform: "browser" | "node" | "neutral"


SameShape<Out, In>

SameShape<Out, In>: In & { [Key in Exclude<keyof In, keyof Out>]: never }

Type Parameters

Type Parameter

Out

In extends Out

Variables

version

version: string

Functions

analyzeMetafile()

analyzeMetafile(metafile, options?): Promise<string>

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

Parameters

ParameterType

metafile

string | Metafile

options?

AnalyzeMetafileOptions

Returns

Promise<string>


analyzeMetafileSync()

analyzeMetafileSync(metafile, options?): string

A synchronous version of "analyzeMetafile".

  • Works in node: yes
  • Works in browser: no

Documentation: https://esbuild.github.io/api/#analyze

Parameters

ParameterType

metafile

string | Metafile

options?

AnalyzeMetafileOptions

Returns

string


build()

build<T>(options): Promise<BuildResult<T>>

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

Type Parameters

Type Parameter

T extends BuildOptions

Parameters

ParameterType

options

SameShape<BuildOptions, T>

Returns

Promise<BuildResult<T>>


buildSync()

buildSync<T>(options): BuildResult<T>

A synchronous version of "build".

  • Works in node: yes
  • Works in browser: no

Documentation: https://esbuild.github.io/api/#build

Type Parameters

Type Parameter

T extends BuildOptions

Parameters

ParameterType

options

SameShape<BuildOptions, T>

Returns

BuildResult<T>


context()

context<T>(options): Promise<BuildContext<T>>

This is the advanced long-running form of "build" that supports additional features such as watch mode and a local development server.

  • Works in node: yes
  • Works in browser: no

Documentation: https://esbuild.github.io/api/#build

Type Parameters

Type Parameter

T extends BuildOptions

Parameters

ParameterType

options

SameShape<BuildOptions, T>

Returns

Promise<BuildContext<T>>


formatMessages()

formatMessages(messages, options): Promise<string[]>

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

Parameters

ParameterType

messages

PartialMessage[]

options

FormatMessagesOptions

Returns

Promise<string[]>


formatMessagesSync()

formatMessagesSync(messages, options): string[]

A synchronous version of "formatMessages".

  • Works in node: yes
  • Works in browser: no

Parameters

ParameterType

messages

PartialMessage[]

options

FormatMessagesOptions

Returns

string[]


initialize()

initialize(options): Promise<void>

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/#browser

Parameters

ParameterType

options

InitializeOptions

Returns

Promise<void>


stop()

stop(): Promise<void>

Returns

Promise<void>


transform()

transform<T>(input, options?): Promise<TransformResult<T>>

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

Type Parameters

Type Parameter

T extends TransformOptions

Parameters

ParameterType

input

string | Uint8Array<ArrayBufferLike>

options?

SameShape<TransformOptions, T>

Returns

Promise<TransformResult<T>>


transformSync()

transformSync<T>(input, options?): TransformResult<T>

A synchronous version of "transform".

  • Works in node: yes
  • Works in browser: no

Documentation: https://esbuild.github.io/api/#transform

Type Parameters

Type Parameter

T extends TransformOptions

Parameters

ParameterType

input

string | Uint8Array<ArrayBufferLike>

options?

SameShape<TransformOptions, T>

Returns

TransformResult<T>