isomorfeus-asset-manager 0.16.4 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,256 +1,235 @@
1
- export type Platform = 'browser' | 'node' | 'neutral';
2
- export type Format = 'iife' | 'cjs' | 'esm';
3
- export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx';
4
- export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
5
- export type Charset = 'ascii' | 'utf8';
6
- export type Drop = 'console' | 'debugger';
1
+ export type Platform = 'browser' | 'node' | 'neutral'
2
+ export type Format = 'iife' | 'cjs' | 'esm'
3
+ export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'text' | 'ts' | 'tsx'
4
+ export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'
5
+ export type Charset = 'ascii' | 'utf8'
6
+ export type Drop = 'console' | 'debugger'
7
7
 
8
8
  interface CommonOptions {
9
9
  /** Documentation: https://esbuild.github.io/api/#sourcemap */
10
- sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
10
+ sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'
11
11
  /** Documentation: https://esbuild.github.io/api/#legal-comments */
12
- legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external';
12
+ legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'
13
13
  /** Documentation: https://esbuild.github.io/api/#source-root */
14
- sourceRoot?: string;
14
+ sourceRoot?: string
15
15
  /** Documentation: https://esbuild.github.io/api/#sources-content */
16
- sourcesContent?: boolean;
16
+ sourcesContent?: boolean
17
17
 
18
18
  /** Documentation: https://esbuild.github.io/api/#format */
19
- format?: Format;
19
+ format?: Format
20
20
  /** Documentation: https://esbuild.github.io/api/#global-name */
21
- globalName?: string;
21
+ globalName?: string
22
22
  /** Documentation: https://esbuild.github.io/api/#target */
23
- target?: string | string[];
23
+ target?: string | string[]
24
24
  /** Documentation: https://esbuild.github.io/api/#supported */
25
- supported?: Record<string, boolean>;
25
+ supported?: Record<string, boolean>
26
26
  /** Documentation: https://esbuild.github.io/api/#platform */
27
- platform?: Platform;
27
+ platform?: Platform
28
28
 
29
29
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
- mangleProps?: RegExp;
30
+ mangleProps?: RegExp
31
31
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
32
- reserveProps?: RegExp;
32
+ reserveProps?: RegExp
33
33
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
34
- mangleQuoted?: boolean;
34
+ mangleQuoted?: boolean
35
35
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
36
- mangleCache?: Record<string, string | false>;
36
+ mangleCache?: Record<string, string | false>
37
37
  /** Documentation: https://esbuild.github.io/api/#drop */
38
- drop?: Drop[];
38
+ drop?: Drop[]
39
39
  /** Documentation: https://esbuild.github.io/api/#minify */
40
- minify?: boolean;
40
+ minify?: boolean
41
41
  /** Documentation: https://esbuild.github.io/api/#minify */
42
- minifyWhitespace?: boolean;
42
+ minifyWhitespace?: boolean
43
43
  /** Documentation: https://esbuild.github.io/api/#minify */
44
- minifyIdentifiers?: boolean;
44
+ minifyIdentifiers?: boolean
45
45
  /** Documentation: https://esbuild.github.io/api/#minify */
46
- minifySyntax?: boolean;
46
+ minifySyntax?: boolean
47
47
  /** Documentation: https://esbuild.github.io/api/#charset */
48
- charset?: Charset;
48
+ charset?: Charset
49
49
  /** Documentation: https://esbuild.github.io/api/#tree-shaking */
50
- treeShaking?: boolean;
50
+ treeShaking?: boolean
51
51
  /** Documentation: https://esbuild.github.io/api/#ignore-annotations */
52
- ignoreAnnotations?: boolean;
52
+ ignoreAnnotations?: boolean
53
53
 
54
54
  /** Documentation: https://esbuild.github.io/api/#jsx */
55
- jsx?: 'transform' | 'preserve' | 'automatic';
55
+ jsx?: 'transform' | 'preserve' | 'automatic'
56
56
  /** Documentation: https://esbuild.github.io/api/#jsx-factory */
57
- jsxFactory?: string;
57
+ jsxFactory?: string
58
58
  /** Documentation: https://esbuild.github.io/api/#jsx-fragment */
59
- jsxFragment?: string;
59
+ jsxFragment?: string
60
60
  /** Documentation: https://esbuild.github.io/api/#jsx-import-source */
61
- jsxImportSource?: string;
61
+ jsxImportSource?: string
62
62
  /** Documentation: https://esbuild.github.io/api/#jsx-development */
63
- jsxDev?: boolean;
63
+ jsxDev?: boolean
64
64
  /** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
65
- jsxSideEffects?: boolean;
65
+ jsxSideEffects?: boolean
66
66
 
67
67
  /** Documentation: https://esbuild.github.io/api/#define */
68
- define?: { [key: string]: string };
68
+ define?: { [key: string]: string }
69
69
  /** Documentation: https://esbuild.github.io/api/#pure */
70
- pure?: string[];
70
+ pure?: string[]
71
71
  /** Documentation: https://esbuild.github.io/api/#keep-names */
72
- keepNames?: boolean;
72
+ keepNames?: boolean
73
73
 
74
74
  /** Documentation: https://esbuild.github.io/api/#color */
75
- color?: boolean;
75
+ color?: boolean
76
76
  /** Documentation: https://esbuild.github.io/api/#log-level */
77
- logLevel?: LogLevel;
77
+ logLevel?: LogLevel
78
78
  /** Documentation: https://esbuild.github.io/api/#log-limit */
79
- logLimit?: number;
79
+ logLimit?: number
80
80
  /** Documentation: https://esbuild.github.io/api/#log-override */
81
- logOverride?: Record<string, LogLevel>;
81
+ logOverride?: Record<string, LogLevel>
82
82
  }
83
83
 
84
84
  export interface BuildOptions extends CommonOptions {
85
85
  /** Documentation: https://esbuild.github.io/api/#bundle */
86
- bundle?: boolean;
86
+ bundle?: boolean
87
87
  /** Documentation: https://esbuild.github.io/api/#splitting */
88
- splitting?: boolean;
88
+ splitting?: boolean
89
89
  /** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
90
- preserveSymlinks?: boolean;
90
+ preserveSymlinks?: boolean
91
91
  /** Documentation: https://esbuild.github.io/api/#outfile */
92
- outfile?: string;
92
+ outfile?: string
93
93
  /** Documentation: https://esbuild.github.io/api/#metafile */
94
- metafile?: boolean;
94
+ metafile?: boolean
95
95
  /** Documentation: https://esbuild.github.io/api/#outdir */
96
- outdir?: string;
96
+ outdir?: string
97
97
  /** Documentation: https://esbuild.github.io/api/#outbase */
98
- outbase?: string;
98
+ outbase?: string
99
99
  /** Documentation: https://esbuild.github.io/api/#external */
100
- external?: string[];
100
+ external?: string[]
101
101
  /** Documentation: https://esbuild.github.io/api/#packages */
102
- packages?: 'external';
102
+ packages?: 'external'
103
103
  /** Documentation: https://esbuild.github.io/api/#alias */
104
- alias?: Record<string, string>;
104
+ alias?: Record<string, string>
105
105
  /** Documentation: https://esbuild.github.io/api/#loader */
106
- loader?: { [ext: string]: Loader };
106
+ loader?: { [ext: string]: Loader }
107
107
  /** Documentation: https://esbuild.github.io/api/#resolve-extensions */
108
- resolveExtensions?: string[];
108
+ resolveExtensions?: string[]
109
109
  /** Documentation: https://esbuild.github.io/api/#main-fields */
110
- mainFields?: string[];
110
+ mainFields?: string[]
111
111
  /** Documentation: https://esbuild.github.io/api/#conditions */
112
- conditions?: string[];
112
+ conditions?: string[]
113
113
  /** Documentation: https://esbuild.github.io/api/#write */
114
- write?: boolean;
114
+ write?: boolean
115
115
  /** Documentation: https://esbuild.github.io/api/#allow-overwrite */
116
- allowOverwrite?: boolean;
116
+ allowOverwrite?: boolean
117
117
  /** Documentation: https://esbuild.github.io/api/#tsconfig */
118
- tsconfig?: string;
118
+ tsconfig?: string
119
119
  /** Documentation: https://esbuild.github.io/api/#out-extension */
120
- outExtension?: { [ext: string]: string };
120
+ outExtension?: { [ext: string]: string }
121
121
  /** Documentation: https://esbuild.github.io/api/#public-path */
122
- publicPath?: string;
122
+ publicPath?: string
123
123
  /** Documentation: https://esbuild.github.io/api/#entry-names */
124
- entryNames?: string;
124
+ entryNames?: string
125
125
  /** Documentation: https://esbuild.github.io/api/#chunk-names */
126
- chunkNames?: string;
126
+ chunkNames?: string
127
127
  /** Documentation: https://esbuild.github.io/api/#asset-names */
128
- assetNames?: string;
128
+ assetNames?: string
129
129
  /** Documentation: https://esbuild.github.io/api/#inject */
130
- inject?: string[];
130
+ inject?: string[]
131
131
  /** Documentation: https://esbuild.github.io/api/#banner */
132
- banner?: { [type: string]: string };
132
+ banner?: { [type: string]: string }
133
133
  /** Documentation: https://esbuild.github.io/api/#footer */
134
- footer?: { [type: string]: string };
135
- /** Documentation: https://esbuild.github.io/api/#incremental */
136
- incremental?: boolean;
134
+ footer?: { [type: string]: string }
137
135
  /** Documentation: https://esbuild.github.io/api/#entry-points */
138
- entryPoints?: string[] | Record<string, string>;
136
+ entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
139
137
  /** Documentation: https://esbuild.github.io/api/#stdin */
140
- stdin?: StdinOptions;
138
+ stdin?: StdinOptions
141
139
  /** Documentation: https://esbuild.github.io/plugins/ */
142
- plugins?: Plugin[];
140
+ plugins?: Plugin[]
143
141
  /** Documentation: https://esbuild.github.io/api/#working-directory */
144
- absWorkingDir?: string;
142
+ absWorkingDir?: string
145
143
  /** Documentation: https://esbuild.github.io/api/#node-paths */
146
144
  nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
147
- /** Documentation: https://esbuild.github.io/api/#watch */
148
- watch?: boolean | WatchMode;
149
- }
150
-
151
- export interface WatchMode {
152
- onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void;
153
145
  }
154
146
 
155
147
  export interface StdinOptions {
156
- contents: string | Uint8Array;
157
- resolveDir?: string;
158
- sourcefile?: string;
159
- loader?: Loader;
148
+ contents: string | Uint8Array
149
+ resolveDir?: string
150
+ sourcefile?: string
151
+ loader?: Loader
160
152
  }
161
153
 
162
154
  export interface Message {
163
- id: string;
164
- pluginName: string;
165
- text: string;
166
- location: Location | null;
167
- notes: Note[];
155
+ id: string
156
+ pluginName: string
157
+ text: string
158
+ location: Location | null
159
+ notes: Note[]
168
160
 
169
161
  /**
170
162
  * Optional user-specified data that is passed through unmodified. You can
171
163
  * use this to stash the original error, for example.
172
164
  */
173
- detail: any;
165
+ detail: any
174
166
  }
175
167
 
176
168
  export interface Note {
177
- text: string;
178
- location: Location | null;
169
+ text: string
170
+ location: Location | null
179
171
  }
180
172
 
181
173
  export interface Location {
182
- file: string;
183
- namespace: string;
174
+ file: string
175
+ namespace: string
184
176
  /** 1-based */
185
- line: number;
177
+ line: number
186
178
  /** 0-based, in bytes */
187
- column: number;
179
+ column: number
188
180
  /** in bytes */
189
- length: number;
190
- lineText: string;
191
- suggestion: string;
181
+ length: number
182
+ lineText: string
183
+ suggestion: string
192
184
  }
193
185
 
194
186
  export interface OutputFile {
195
- path: string;
187
+ path: string
196
188
  /** "text" as bytes */
197
- contents: Uint8Array;
189
+ contents: Uint8Array
198
190
  /** "contents" as text (changes automatically with "contents") */
199
- readonly text: string;
200
- }
201
-
202
- export interface BuildInvalidate {
203
- (): Promise<BuildIncremental>;
204
- dispose(): void;
205
- }
206
-
207
- export interface BuildIncremental extends BuildResult {
208
- rebuild: BuildInvalidate;
191
+ readonly text: string
209
192
  }
210
193
 
211
- export interface BuildResult {
212
- errors: Message[];
213
- warnings: Message[];
194
+ export interface BuildResult<SpecificOptions extends BuildOptions = BuildOptions> {
195
+ errors: Message[]
196
+ warnings: Message[]
214
197
  /** Only when "write: false" */
215
- outputFiles?: OutputFile[];
216
- /** Only when "incremental: true" */
217
- rebuild?: BuildInvalidate;
218
- /** Only when "watch: true" */
219
- stop?: () => void;
198
+ outputFiles: OutputFile[] | (SpecificOptions['write'] extends false ? never : undefined)
220
199
  /** Only when "metafile: true" */
221
- metafile?: Metafile;
200
+ metafile: Metafile | (SpecificOptions['metafile'] extends true ? never : undefined)
222
201
  /** Only when "mangleCache" is present */
223
- mangleCache?: Record<string, string | false>;
202
+ mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined)
224
203
  }
225
204
 
226
205
  export interface BuildFailure extends Error {
227
- errors: Message[];
228
- warnings: Message[];
206
+ errors: Message[]
207
+ warnings: Message[]
229
208
  }
230
209
 
231
210
  /** Documentation: https://esbuild.github.io/api/#serve-arguments */
232
211
  export interface ServeOptions {
233
- port?: number;
234
- host?: string;
235
- servedir?: string;
236
- onRequest?: (args: ServeOnRequestArgs) => void;
212
+ port?: number
213
+ host?: string
214
+ servedir?: string
215
+ keyfile?: string
216
+ certfile?: string
217
+ onRequest?: (args: ServeOnRequestArgs) => void
237
218
  }
238
219
 
239
220
  export interface ServeOnRequestArgs {
240
- remoteAddress: string;
241
- method: string;
242
- path: string;
243
- status: number;
221
+ remoteAddress: string
222
+ method: string
223
+ path: string
224
+ status: number
244
225
  /** The time to generate the response, not to send it */
245
- timeInMS: number;
226
+ timeInMS: number
246
227
  }
247
228
 
248
229
  /** Documentation: https://esbuild.github.io/api/#serve-return-values */
249
230
  export interface ServeResult {
250
- port: number;
251
- host: string;
252
- wait: Promise<void>;
253
- stop: () => void;
231
+ port: number
232
+ host: string
254
233
  }
255
234
 
256
235
  export interface TransformOptions extends CommonOptions {
@@ -266,50 +245,63 @@ export interface TransformOptions extends CommonOptions {
266
245
  target?: string,
267
246
  useDefineForClassFields?: boolean,
268
247
  },
269
- };
248
+ }
270
249
 
271
- sourcefile?: string;
272
- loader?: Loader;
273
- banner?: string;
274
- footer?: string;
250
+ sourcefile?: string
251
+ loader?: Loader
252
+ banner?: string
253
+ footer?: string
275
254
  }
276
255
 
277
- export interface TransformResult {
278
- code: string;
279
- map: string;
280
- warnings: Message[];
256
+ export interface TransformResult<SpecificOptions extends TransformOptions = TransformOptions> {
257
+ code: string
258
+ map: string
259
+ warnings: Message[]
281
260
  /** Only when "mangleCache" is present */
282
- mangleCache?: Record<string, string | false>;
261
+ mangleCache: Record<string, string | false> | (SpecificOptions['mangleCache'] extends Object ? never : undefined)
283
262
  /** Only when "legalComments" is "external" */
284
- legalComments?: string;
263
+ legalComments: string | (SpecificOptions['legalComments'] extends 'external' ? never : undefined)
285
264
  }
286
265
 
287
266
  export interface TransformFailure extends Error {
288
- errors: Message[];
289
- warnings: Message[];
267
+ errors: Message[]
268
+ warnings: Message[]
290
269
  }
291
270
 
292
271
  export interface Plugin {
293
- name: string;
294
- setup: (build: PluginBuild) => (void | Promise<void>);
272
+ name: string
273
+ setup: (build: PluginBuild) => (void | Promise<void>)
295
274
  }
296
275
 
297
276
  export interface PluginBuild {
298
- initialOptions: BuildOptions;
299
- resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>;
277
+ /** Documentation: https://esbuild.github.io/plugins/#build-options */
278
+ initialOptions: BuildOptions
279
+
280
+ /** Documentation: https://esbuild.github.io/plugins/#resolve */
281
+ resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
300
282
 
283
+ /** Documentation: https://esbuild.github.io/plugins/#on-start */
301
284
  onStart(callback: () =>
302
- (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
285
+ (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
286
+
287
+ /** Documentation: https://esbuild.github.io/plugins/#on-end */
303
288
  onEnd(callback: (result: BuildResult) =>
304
- (void | Promise<void>)): void;
289
+ (OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
290
+
291
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve */
305
292
  onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
306
- (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;
293
+ (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
294
+
295
+ /** Documentation: https://esbuild.github.io/plugins/#on-load */
307
296
  onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
308
- (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void;
297
+ (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
298
+
299
+ /** Documentation: https://esbuild.github.io/plugins/#on-dispose */
300
+ onDispose(callback: () => void): void
309
301
 
310
302
  // This is a full copy of the esbuild library in case you need it
311
303
  esbuild: {
312
- serve: typeof serve,
304
+ context: typeof context,
313
305
  build: typeof build,
314
306
  buildSync: typeof buildSync,
315
307
  transform: typeof transform,
@@ -320,47 +312,56 @@ export interface PluginBuild {
320
312
  analyzeMetafileSync: typeof analyzeMetafileSync,
321
313
  initialize: typeof initialize,
322
314
  version: typeof version,
323
- };
315
+ }
324
316
  }
325
317
 
318
+ /** Documentation: https://esbuild.github.io/plugins/#resolve-options */
326
319
  export interface ResolveOptions {
327
- pluginName?: string;
328
- importer?: string;
329
- namespace?: string;
330
- resolveDir?: string;
331
- kind?: ImportKind;
332
- pluginData?: any;
320
+ pluginName?: string
321
+ importer?: string
322
+ namespace?: string
323
+ resolveDir?: string
324
+ kind?: ImportKind
325
+ pluginData?: any
333
326
  }
334
327
 
328
+ /** Documentation: https://esbuild.github.io/plugins/#resolve-results */
335
329
  export interface ResolveResult {
336
- errors: Message[];
337
- warnings: Message[];
330
+ errors: Message[]
331
+ warnings: Message[]
338
332
 
339
- path: string;
340
- external: boolean;
341
- sideEffects: boolean;
342
- namespace: string;
343
- suffix: string;
344
- pluginData: any;
333
+ path: string
334
+ external: boolean
335
+ sideEffects: boolean
336
+ namespace: string
337
+ suffix: string
338
+ pluginData: any
345
339
  }
346
340
 
347
341
  export interface OnStartResult {
348
- errors?: PartialMessage[];
349
- warnings?: PartialMessage[];
342
+ errors?: PartialMessage[]
343
+ warnings?: PartialMessage[]
344
+ }
345
+
346
+ export interface OnEndResult {
347
+ errors?: PartialMessage[]
348
+ warnings?: PartialMessage[]
350
349
  }
351
350
 
351
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
352
352
  export interface OnResolveOptions {
353
- filter: RegExp;
354
- namespace?: string;
353
+ filter: RegExp
354
+ namespace?: string
355
355
  }
356
356
 
357
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
357
358
  export interface OnResolveArgs {
358
- path: string;
359
- importer: string;
360
- namespace: string;
361
- resolveDir: string;
362
- kind: ImportKind;
363
- pluginData: any;
359
+ path: string
360
+ importer: string
361
+ namespace: string
362
+ resolveDir: string
363
+ kind: ImportKind
364
+ pluginData: any
364
365
  }
365
366
 
366
367
  export type ImportKind =
@@ -376,64 +377,69 @@ export type ImportKind =
376
377
  | 'import-rule'
377
378
  | 'url-token'
378
379
 
380
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
379
381
  export interface OnResolveResult {
380
- pluginName?: string;
382
+ pluginName?: string
381
383
 
382
- errors?: PartialMessage[];
383
- warnings?: PartialMessage[];
384
+ errors?: PartialMessage[]
385
+ warnings?: PartialMessage[]
384
386
 
385
- path?: string;
386
- external?: boolean;
387
- sideEffects?: boolean;
388
- namespace?: string;
389
- suffix?: string;
390
- pluginData?: any;
387
+ path?: string
388
+ external?: boolean
389
+ sideEffects?: boolean
390
+ namespace?: string
391
+ suffix?: string
392
+ pluginData?: any
391
393
 
392
- watchFiles?: string[];
393
- watchDirs?: string[];
394
+ watchFiles?: string[]
395
+ watchDirs?: string[]
394
396
  }
395
397
 
398
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-options */
396
399
  export interface OnLoadOptions {
397
- filter: RegExp;
398
- namespace?: string;
400
+ filter: RegExp
401
+ namespace?: string
399
402
  }
400
403
 
404
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
401
405
  export interface OnLoadArgs {
402
- path: string;
403
- namespace: string;
404
- suffix: string;
405
- pluginData: any;
406
+ path: string
407
+ namespace: string
408
+ suffix: string
409
+ pluginData: any
406
410
  }
407
411
 
412
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-results */
408
413
  export interface OnLoadResult {
409
- pluginName?: string;
414
+ pluginName?: string
410
415
 
411
- errors?: PartialMessage[];
412
- warnings?: PartialMessage[];
416
+ errors?: PartialMessage[]
417
+ warnings?: PartialMessage[]
413
418
 
414
- contents?: string | Uint8Array;
415
- resolveDir?: string;
416
- loader?: Loader;
417
- pluginData?: any;
419
+ contents?: string | Uint8Array
420
+ resolveDir?: string
421
+ loader?: Loader
422
+ pluginData?: any
418
423
 
419
- watchFiles?: string[];
420
- watchDirs?: string[];
424
+ watchFiles?: string[]
425
+ watchDirs?: string[]
421
426
  }
422
427
 
423
428
  export interface PartialMessage {
424
- id?: string;
425
- pluginName?: string;
426
- text?: string;
427
- location?: Partial<Location> | null;
428
- notes?: PartialNote[];
429
- detail?: any;
429
+ id?: string
430
+ pluginName?: string
431
+ text?: string
432
+ location?: Partial<Location> | null
433
+ notes?: PartialNote[]
434
+ detail?: any
430
435
  }
431
436
 
432
437
  export interface PartialNote {
433
- text?: string;
434
- location?: Partial<Location> | null;
438
+ text?: string
439
+ location?: Partial<Location> | null
435
440
  }
436
441
 
442
+ /** Documentation: https://esbuild.github.io/api/#metafile */
437
443
  export interface Metafile {
438
444
  inputs: {
439
445
  [path: string]: {
@@ -468,14 +474,31 @@ export interface Metafile {
468
474
  }
469
475
 
470
476
  export interface FormatMessagesOptions {
471
- kind: 'error' | 'warning';
472
- color?: boolean;
473
- terminalWidth?: number;
477
+ kind: 'error' | 'warning'
478
+ color?: boolean
479
+ terminalWidth?: number
474
480
  }
475
481
 
476
482
  export interface AnalyzeMetafileOptions {
477
- color?: boolean;
478
- verbose?: boolean;
483
+ color?: boolean
484
+ verbose?: boolean
485
+ }
486
+
487
+ export interface WatchOptions {
488
+ }
489
+
490
+ export interface BuildContext<SpecificOptions extends BuildOptions = BuildOptions> {
491
+ /** Documentation: https://esbuild.github.io/api/#rebuild */
492
+ rebuild(): Promise<BuildResult<SpecificOptions>>
493
+
494
+ /** Documentation: https://esbuild.github.io/api/#watch */
495
+ watch(options?: WatchOptions): Promise<void>
496
+
497
+ /** Documentation: https://esbuild.github.io/api/#serve */
498
+ serve(options?: ServeOptions): Promise<ServeResult>
499
+
500
+ cancel(): Promise<void>
501
+ dispose(): Promise<void>
479
502
  }
480
503
 
481
504
  /**
@@ -486,24 +509,22 @@ export interface AnalyzeMetafileOptions {
486
509
  * - Works in node: yes
487
510
  * - Works in browser: yes
488
511
  *
489
- * Documentation: https://esbuild.github.io/api/#build-api
512
+ * Documentation: https://esbuild.github.io/api/#build
490
513
  */
491
- export declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>;
492
- export declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise<BuildIncremental & { metafile: Metafile }>;
493
- export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>;
494
- export declare function build(options: BuildOptions & { metafile: true }): Promise<BuildResult & { metafile: Metafile }>;
495
- export declare function build(options: BuildOptions): Promise<BuildResult>;
514
+ export declare function build<SpecificOptions extends BuildOptions>(options: SpecificOptions): Promise<BuildResult<SpecificOptions>>
515
+ export declare function build(options: BuildOptions): Promise<BuildResult>
496
516
 
497
517
  /**
498
- * This function is similar to "build" but it serves the resulting files over
499
- * HTTP on a localhost address with the specified port.
518
+ * This is the advanced long-running form of "build" that supports additional
519
+ * features such as watch mode and a local development server.
500
520
  *
501
521
  * - Works in node: yes
502
522
  * - Works in browser: no
503
523
  *
504
- * Documentation: https://esbuild.github.io/api/#serve
524
+ * Documentation: https://esbuild.github.io/api/#build
505
525
  */
506
- export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise<ServeResult>;
526
+ export declare function context<T extends BuildOptions>(options: T): Promise<BuildContext<T>>
527
+ export declare function context(options: BuildOptions): Promise<BuildContext>
507
528
 
508
529
  /**
509
530
  * This function transforms a single JavaScript file. It can be used to minify
@@ -514,9 +535,10 @@ export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOpt
514
535
  * - Works in node: yes
515
536
  * - Works in browser: yes
516
537
  *
517
- * Documentation: https://esbuild.github.io/api/#transform-api
538
+ * Documentation: https://esbuild.github.io/api/#transform
518
539
  */
519
- export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>;
540
+ export declare function transform<SpecificOptions extends TransformOptions>(input: string | Uint8Array, options?: SpecificOptions): Promise<TransformResult<SpecificOptions>>
541
+ export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>
520
542
 
521
543
  /**
522
544
  * Converts log messages to formatted message strings suitable for printing in
@@ -526,7 +548,7 @@ export declare function transform(input: string | Uint8Array, options?: Transfor
526
548
  * - Works in node: yes
527
549
  * - Works in browser: yes
528
550
  */
529
- export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
551
+ export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
530
552
 
531
553
  /**
532
554
  * Pretty-prints an analysis of the metafile JSON to a string. This is just for
@@ -538,7 +560,7 @@ export declare function formatMessages(messages: PartialMessage[], options: Form
538
560
  *
539
561
  * Documentation: https://esbuild.github.io/api/#analyze
540
562
  */
541
- export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
563
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
542
564
 
543
565
  /**
544
566
  * A synchronous version of "build".
@@ -546,10 +568,10 @@ export declare function analyzeMetafile(metafile: Metafile | string, options?: A
546
568
  * - Works in node: yes
547
569
  * - Works in browser: no
548
570
  *
549
- * Documentation: https://esbuild.github.io/api/#build-api
571
+ * Documentation: https://esbuild.github.io/api/#build
550
572
  */
551
- export declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] };
552
- export declare function buildSync(options: BuildOptions): BuildResult;
573
+ export declare function buildSync<SpecificOptions extends BuildOptions>(options: SpecificOptions): BuildResult<SpecificOptions>
574
+ export declare function buildSync(options: BuildOptions): BuildResult
553
575
 
554
576
  /**
555
577
  * A synchronous version of "transform".
@@ -557,9 +579,10 @@ export declare function buildSync(options: BuildOptions): BuildResult;
557
579
  * - Works in node: yes
558
580
  * - Works in browser: no
559
581
  *
560
- * Documentation: https://esbuild.github.io/api/#transform-api
582
+ * Documentation: https://esbuild.github.io/api/#transform
561
583
  */
562
- export declare function transformSync(input: string, options?: TransformOptions): TransformResult;
584
+ export declare function transformSync<SpecificOptions extends TransformOptions>(input: string, options?: SpecificOptions): TransformResult<SpecificOptions>
585
+ export declare function transformSync(input: string | Uint8Array, options?: TransformOptions): TransformResult
563
586
 
564
587
  /**
565
588
  * A synchronous version of "formatMessages".
@@ -567,7 +590,7 @@ export declare function transformSync(input: string, options?: TransformOptions)
567
590
  * - Works in node: yes
568
591
  * - Works in browser: no
569
592
  */
570
- export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
593
+ export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
571
594
 
572
595
  /**
573
596
  * A synchronous version of "analyzeMetafile".
@@ -577,7 +600,7 @@ export declare function formatMessagesSync(messages: PartialMessage[], options:
577
600
  *
578
601
  * Documentation: https://esbuild.github.io/api/#analyze
579
602
  */
580
- export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
603
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
581
604
 
582
605
  /**
583
606
  * This configures the browser-based version of esbuild. It is necessary to
@@ -587,9 +610,9 @@ export declare function analyzeMetafileSync(metafile: Metafile | string, options
587
610
  * - Works in node: yes
588
611
  * - Works in browser: yes ("options" is required)
589
612
  *
590
- * Documentation: https://esbuild.github.io/api/#running-in-the-browser
613
+ * Documentation: https://esbuild.github.io/api/#browser
591
614
  */
592
- export declare function initialize(options: InitializeOptions): Promise<void>;
615
+ export declare function initialize(options: InitializeOptions): Promise<void>
593
616
 
594
617
  export interface InitializeOptions {
595
618
  /**
@@ -616,4 +639,4 @@ export interface InitializeOptions {
616
639
  worker?: boolean
617
640
  }
618
641
 
619
- export let version: string;
642
+ export let version: string