-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule_esbuild.d.ts
322 lines (271 loc) · 14.7 KB
/
module_esbuild.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
declare module "go/esbuild" {
// ifTerminal,never,always
type StderrColor = 0 | 1 | 2
// silent,verbose,debug,info,warning,error
type LogLevel = 0 | 1 | 2 | 3 | 4 | 5
//0: default, 1: ASCII 2: UTF8
type Charset = 0 | 1 | 2
//default,false,true
type TreeShaking = 0 | 1 | 2
//Include,Exclude
type SourcesContent = 0 | 1
/**
* Default,None,Inline,EndOfFile,Linked,External
*/
type LegalComments = 0 | 1 | 2 | 3 | 4 | 5
/**
* Transform, Preserve, Automatic
*/
type JSX = 0 | 1 | 2
//console,debugger
type Drop = 1 | 2
/**
* Default,ESNext,ES5,ES2015,ES2016,ES2017,ES2018,ES2019,ES2020,ES2021,ES2022
*/
type Target = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
/**
* None,Inline,Linked,External,InlineAndExternal
*/
type SourceMap = 0 | 1 | 2 | 3 | 4
/**
* LoaderNone , LoaderBase64, LoaderBinary, LoaderCopy, LoaderCSS, LoaderDataURL, LoaderDefault, LoaderEmpty, LoaderFile, LoaderGlobalCSS, LoaderJS, LoaderJSON, LoaderJSX, LoaderLocalCSS, LoaderText, LoaderTS, LoaderTSX
*/
type Loader = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16
//false,true
type MangleQuoted = 0 | 1
/**
* Default,Browser,Node,Neutral
*/
type Platform = 0 | 1 | 2 | 3
/**
* default,IIFE,CommonJs,ESM
*/
type Format = 0 | 1 | 2 | 3
/**
* default,external
*/
type Packages = 0 | 1
/**
* Chrome,Deno,Edge,Firefox,Hermes,IE,IOS,Node,Opera,Rhino,Safari
*/
type EngineName = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
export interface Engine {
name: EngineName
version: string
}
export interface TransformOptions {
color?: StderrColor // Documentation: https://esbuild.github.io/api/#color
logLevel?: LogLevel // Documentation: https://esbuild.github.io/api/#log-level
logLimit?: number // Documentation: https://esbuild.github.io/api/#log-limit
logOverride?: { [key: string]: LogLevel } // Documentation: https://esbuild.github.io/api/#log-override
sourcemap?: SourceMap // Documentation: https://esbuild.github.io/api/#sourcemap
sourceRoot?: string // Documentation: https://esbuild.github.io/api/#source-root
sourcesContent?: SourcesContent // Documentation: https://esbuild.github.io/api/#sources-content
target?: Target // Documentation: https://esbuild.github.io/api/#target
engines?: Engine[] // Documentation: https://esbuild.github.io/api/#target
supported?: { [key: string]: boolean } // Documentation: https://esbuild.github.io/api/#supported
platform?: Platform // Documentation: https://esbuild.github.io/api/#platform
format?: Format // Documentation: https://esbuild.github.io/api/#format
globalName?: string // Documentation: https://esbuild.github.io/api/#global-name
mangleProps?: string // Documentation: https://esbuild.github.io/api/#mangle-props
reserveProps?: string // Documentation: https://esbuild.github.io/api/#mangle-props
mangleQuoted?: MangleQuoted // Documentation: https://esbuild.github.io/api/#mangle-props
mangleCache?: Record<string, any>// Documentation: https://esbuild.github.io/api/#mangle-props
drop?: Drop // Documentation: https://esbuild.github.io/api/#drop
dropLabels?: string[] // Documentation: https://esbuild.github.io/api/#drop-labels
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/#minify
lineLimit?: number //int // Documentation: https://esbuild.github.io/api/#line-limit
charset?: Charset // Documentation: https://esbuild.github.io/api/#charset
treeShaking?: TreeShaking // Documentation: https://esbuild.github.io/api/#tree-shaking
ignoreAnnotations?: boolean // Documentation: https://esbuild.github.io/api/#ignore-annotations
legalComments?: LegalComments // Documentation: https://esbuild.github.io/api/#legal-comments
jsx?: JSX // Documentation: https://esbuild.github.io/api/#jsx
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
jsxDev?: boolean // Documentation: https://esbuild.github.io/api/#jsx-dev
jsxSideEffects?: boolean // Documentation: https://esbuild.github.io/api/#jsx-side-effects
tsconfigRaw?: string // Documentation: https://esbuild.github.io/api/#tsconfig-raw
banner?: string // Documentation: https://esbuild.github.io/api/#banner
footer?: string // Documentation: https://esbuild.github.io/api/#footer
define?: Record<string, string>// Documentation: https://esbuild.github.io/api/#define
pure?: string[] // Documentation: https://esbuild.github.io/api/#pure
keepNames?: boolean // Documentation: https://esbuild.github.io/api/#keep-names
sourcefile?: string // Documentation: https://esbuild.github.io/api/#sourcefile
loader?: Loader // Documentation: https://esbuild.github.io/api/#loader
}
export interface TransformResult {
errors?: Message[]
warnings?: Message[]
code?: Uint8Array
map?: Uint8Array
legalComments?: Uint8Array
mangleCache: Record<string, any>
}
export function transform(input: string, options: TransformOptions): TransformResult
export interface StdinOptions {
contents: string
resolveDir: string
sourcefile: string
loader: Loader
}
export interface EntryPoint {
inputPath: string
outputPath: string
}
export interface BuildResult {
errors: Message[]
warnings: Message[]
outputFiles: OutputFile[]
metafile: string
mangleCache: Record<string, any>
}
export interface OutputFile {
path: string
contents: Uint8Array
hash: string
}
export interface BuildOptions {
color?: StderrColor // Documentation: https://esbuild.github.io/api/#color
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
sourcemap?: SourceMap // Documentation: https://esbuild.github.io/api/#sourcemap
sourceRoot?: string // Documentation: https://esbuild.github.io/api/#source-root
sourcesContent?: SourcesContent // Documentation: https://esbuild.github.io/api/#sources-content
target?: Target // Documentation: https://esbuild.github.io/api/#target
engines?: Engine[] // Documentation: https://esbuild.github.io/api/#target
supported?: Record<string, boolean> // Documentation: https://esbuild.github.io/api/#supported
mangleProps?: string // Documentation: https://esbuild.github.io/api/#mangle-props
reserveProps?: string // Documentation: https://esbuild.github.io/api/#mangle-props
mangleQuoted?: MangleQuoted // Documentation: https://esbuild.github.io/api/#mangle-props
mangleCache?: Record<string, any> // Documentation: https://esbuild.github.io/api/#mangle-props
drop?: Drop // Documentation: https://esbuild.github.io/api/#drop
dropLabels?: string[] // Documentation: https://esbuild.github.io/api/#drop-labels
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/#minify
lineLimit?: number // Documentation: https://esbuild.github.io/api/#line-limit
charset?: Charset // Documentation: https://esbuild.github.io/api/#charset
treeShaking?: TreeShaking // Documentation: https://esbuild.github.io/api/#tree-shaking
ignoreAnnotations?: boolean // Documentation: https://esbuild.github.io/api/#ignore-annotations
legalComments?: LegalComments // Documentation: https://esbuild.github.io/api/#legal-comments
jsx?: JSX // Documentation: https://esbuild.github.io/api/#jsx-mode
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
jsxDev?: boolean // Documentation: https://esbuild.github.io/api/#jsx-dev
jsxSideEffects?: boolean // Documentation: https://esbuild.github.io/api/#jsx-side-effects
define?: Record<string, string> // Documentation: https://esbuild.github.io/api/#define
pure?: string[] // Documentation: https://esbuild.github.io/api/#pure
keepNames?: boolean // Documentation: https://esbuild.github.io/api/#keep-names
globalName?: string // Documentation: https://esbuild.github.io/api/#global-name
bundle?: boolean // Documentation: https://esbuild.github.io/api/#bundle
preserveSymlinks?: boolean // Documentation: https://esbuild.github.io/api/#preserve-symlinks
splitting?: boolean // Documentation: https://esbuild.github.io/api/#splitting
outfile?: string // Documentation: https://esbuild.github.io/api/#outfile
metafile?: boolean // Documentation: https://esbuild.github.io/api/#metafile
outdir?: string // Documentation: https://esbuild.github.io/api/#outdir
outbase?: string // Documentation: https://esbuild.github.io/api/#outbase
absWorkingDir?: string // Documentation: https://esbuild.github.io/api/#working-directory
platform?: Platform // Documentation: https://esbuild.github.io/api/#platform
format?: Format // Documentation: https://esbuild.github.io/api/#format
external?: string[] // Documentation: https://esbuild.github.io/api/#external
packages?: Packages // Documentation: https://esbuild.github.io/api/#packages
alias?: Record<string, string> // Documentation: https://esbuild.github.io/api/#alias
mainFields?: string[] // Documentation: https://esbuild.github.io/api/#main-fields
conditions?: string[] // Documentation: https://esbuild.github.io/api/#conditions
loader?: Record<string, Loader> // Documentation: https://esbuild.github.io/api/#loader
resolveExtensions?: string[] // Documentation: https://esbuild.github.io/api/#resolve-extensions
tsconfig?: string // Documentation: https://esbuild.github.io/api/#tsconfig
tsconfigRaw?: string // Documentation: https://esbuild.github.io/api/#tsconfig-raw
outExtension?: Record<string, string> // Documentation: https://esbuild.github.io/api/#out-extension
publicPath?: string // Documentation: https://esbuild.github.io/api/#public-path
inject?: string[] // Documentation: https://esbuild.github.io/api/#inject
banner?: Record<string, string> // Documentation: https://esbuild.github.io/api/#banner
footer?: Record<string, string> // Documentation: https://esbuild.github.io/api/#footer
nodePaths?: string[] // Documentation: https://esbuild.github.io/api/#node-paths
entryNames?: string // Documentation: https://esbuild.github.io/api/#entry-names
chunkNames?: string // Documentation: https://esbuild.github.io/api/#chunk-names
assetNames?: string // Documentation: https://esbuild.github.io/api/#asset-names
entryPoints?: string[] // Documentation: https://esbuild.github.io/api/#entry-points
entryPointsAdvanced?: EntryPoint[] // Documentation: https://esbuild.github.io/api/#entry-points
stdin?: StdinOptions // Documentation: https://esbuild.github.io/api/#stdin
write?: boolean // Documentation: https://esbuild.github.io/api/#write
allowOverwrite?: boolean // Documentation: https://esbuild.github.io/api/#allow-overwrite
//plugins?: Plugin[] // Documentation: https://esbuild.github.io/plugins/
}
export function build(options: BuildOptions): BuildResult
export interface ServeOnRequestArgs {
remoteAddress: string
method: string
path: string
status: number //int
timeInMS: number //int // The time to generate the response, not to send it
}
export interface ServeOptions {
port: number //uint16
host: string
servedir: string
keyfile: string
certfile: string
fallback: string
onRequest: (args: ServeOnRequestArgs) => void
}
export interface WatchOptions {
}
export interface ServeResult {
port: string //uint16
host: string
}
export interface ContextError {
errors: Message[] // Option validation errors are returned here
}
export interface BuildContext {
// Documentation: https://esbuild.github.io/api/#rebuild
rebuild(): BuildResult
// Documentation: https://esbuild.github.io/api/#watch
watch(options: WatchOptions)
// Documentation: https://esbuild.github.io/api/#serve
serve(options: ServeOptions): ServeResult
cancel()
dispose()
}
export function context(options: BuildOptions): { context: BuildContext, err: ContextError }
export interface AnalyzeMetafileOptions {
color: boolean
verbose: boolean
}
export interface Location {
file: string
namespace: string
line: number//int // 1-based
column: number// int // 0-based, in bytes
length: number// int // in bytes
lineText: string
suggestion: string
}
export interface Note {
text: string
location?: Location
}
export interface Message {
id: string
pluginName: string
text: string
location?: Location
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 interface FormatMessagesOptions {
terminalWidth: number//int
kind: 0 | 1 // error | warning
color: boolean
}
export function analyzeMetafile(metaFile: string, opts: AnalyzeMetafileOptions): string
export function formatMessages(msg: Message[], opts: FormatMessagesOptions): string[]
}