isomorfeus-asset-manager 0.16.4 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,315 +1,317 @@
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
+
83
+ /** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
84
+ tsconfigRaw?: string | {
85
+ compilerOptions?: {
86
+ alwaysStrict?: boolean
87
+ baseUrl?: boolean
88
+ experimentalDecorators?: boolean
89
+ importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
90
+ jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
91
+ jsxFactory?: string
92
+ jsxFragmentFactory?: string
93
+ jsxImportSource?: string
94
+ paths?: Record<string, string[]>
95
+ preserveValueImports?: boolean
96
+ strict?: boolean
97
+ target?: string
98
+ useDefineForClassFields?: boolean
99
+ verbatimModuleSyntax?: boolean
100
+ }
101
+ }
82
102
  }
83
103
 
84
104
  export interface BuildOptions extends CommonOptions {
85
105
  /** Documentation: https://esbuild.github.io/api/#bundle */
86
- bundle?: boolean;
106
+ bundle?: boolean
87
107
  /** Documentation: https://esbuild.github.io/api/#splitting */
88
- splitting?: boolean;
108
+ splitting?: boolean
89
109
  /** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
90
- preserveSymlinks?: boolean;
110
+ preserveSymlinks?: boolean
91
111
  /** Documentation: https://esbuild.github.io/api/#outfile */
92
- outfile?: string;
112
+ outfile?: string
93
113
  /** Documentation: https://esbuild.github.io/api/#metafile */
94
- metafile?: boolean;
114
+ metafile?: boolean
95
115
  /** Documentation: https://esbuild.github.io/api/#outdir */
96
- outdir?: string;
116
+ outdir?: string
97
117
  /** Documentation: https://esbuild.github.io/api/#outbase */
98
- outbase?: string;
118
+ outbase?: string
99
119
  /** Documentation: https://esbuild.github.io/api/#external */
100
- external?: string[];
120
+ external?: string[]
101
121
  /** Documentation: https://esbuild.github.io/api/#packages */
102
- packages?: 'external';
122
+ packages?: 'external'
103
123
  /** Documentation: https://esbuild.github.io/api/#alias */
104
- alias?: Record<string, string>;
124
+ alias?: Record<string, string>
105
125
  /** Documentation: https://esbuild.github.io/api/#loader */
106
- loader?: { [ext: string]: Loader };
126
+ loader?: { [ext: string]: Loader }
107
127
  /** Documentation: https://esbuild.github.io/api/#resolve-extensions */
108
- resolveExtensions?: string[];
128
+ resolveExtensions?: string[]
109
129
  /** Documentation: https://esbuild.github.io/api/#main-fields */
110
- mainFields?: string[];
130
+ mainFields?: string[]
111
131
  /** Documentation: https://esbuild.github.io/api/#conditions */
112
- conditions?: string[];
132
+ conditions?: string[]
113
133
  /** Documentation: https://esbuild.github.io/api/#write */
114
- write?: boolean;
134
+ write?: boolean
115
135
  /** Documentation: https://esbuild.github.io/api/#allow-overwrite */
116
- allowOverwrite?: boolean;
136
+ allowOverwrite?: boolean
117
137
  /** Documentation: https://esbuild.github.io/api/#tsconfig */
118
- tsconfig?: string;
138
+ tsconfig?: string
119
139
  /** Documentation: https://esbuild.github.io/api/#out-extension */
120
- outExtension?: { [ext: string]: string };
140
+ outExtension?: { [ext: string]: string }
121
141
  /** Documentation: https://esbuild.github.io/api/#public-path */
122
- publicPath?: string;
142
+ publicPath?: string
123
143
  /** Documentation: https://esbuild.github.io/api/#entry-names */
124
- entryNames?: string;
144
+ entryNames?: string
125
145
  /** Documentation: https://esbuild.github.io/api/#chunk-names */
126
- chunkNames?: string;
146
+ chunkNames?: string
127
147
  /** Documentation: https://esbuild.github.io/api/#asset-names */
128
- assetNames?: string;
148
+ assetNames?: string
129
149
  /** Documentation: https://esbuild.github.io/api/#inject */
130
- inject?: string[];
150
+ inject?: string[]
131
151
  /** Documentation: https://esbuild.github.io/api/#banner */
132
- banner?: { [type: string]: string };
152
+ banner?: { [type: string]: string }
133
153
  /** Documentation: https://esbuild.github.io/api/#footer */
134
- footer?: { [type: string]: string };
135
- /** Documentation: https://esbuild.github.io/api/#incremental */
136
- incremental?: boolean;
154
+ footer?: { [type: string]: string }
137
155
  /** Documentation: https://esbuild.github.io/api/#entry-points */
138
- entryPoints?: string[] | Record<string, string>;
156
+ entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
139
157
  /** Documentation: https://esbuild.github.io/api/#stdin */
140
- stdin?: StdinOptions;
158
+ stdin?: StdinOptions
141
159
  /** Documentation: https://esbuild.github.io/plugins/ */
142
- plugins?: Plugin[];
160
+ plugins?: Plugin[]
143
161
  /** Documentation: https://esbuild.github.io/api/#working-directory */
144
- absWorkingDir?: string;
162
+ absWorkingDir?: string
145
163
  /** Documentation: https://esbuild.github.io/api/#node-paths */
146
164
  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
165
  }
154
166
 
155
167
  export interface StdinOptions {
156
- contents: string | Uint8Array;
157
- resolveDir?: string;
158
- sourcefile?: string;
159
- loader?: Loader;
168
+ contents: string | Uint8Array
169
+ resolveDir?: string
170
+ sourcefile?: string
171
+ loader?: Loader
160
172
  }
161
173
 
162
174
  export interface Message {
163
- id: string;
164
- pluginName: string;
165
- text: string;
166
- location: Location | null;
167
- notes: Note[];
175
+ id: string
176
+ pluginName: string
177
+ text: string
178
+ location: Location | null
179
+ notes: Note[]
168
180
 
169
181
  /**
170
182
  * Optional user-specified data that is passed through unmodified. You can
171
183
  * use this to stash the original error, for example.
172
184
  */
173
- detail: any;
185
+ detail: any
174
186
  }
175
187
 
176
188
  export interface Note {
177
- text: string;
178
- location: Location | null;
189
+ text: string
190
+ location: Location | null
179
191
  }
180
192
 
181
193
  export interface Location {
182
- file: string;
183
- namespace: string;
194
+ file: string
195
+ namespace: string
184
196
  /** 1-based */
185
- line: number;
197
+ line: number
186
198
  /** 0-based, in bytes */
187
- column: number;
199
+ column: number
188
200
  /** in bytes */
189
- length: number;
190
- lineText: string;
191
- suggestion: string;
201
+ length: number
202
+ lineText: string
203
+ suggestion: string
192
204
  }
193
205
 
194
206
  export interface OutputFile {
195
- path: string;
207
+ path: string
196
208
  /** "text" as bytes */
197
- contents: Uint8Array;
209
+ contents: Uint8Array
198
210
  /** "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;
211
+ readonly text: string
209
212
  }
210
213
 
211
- export interface BuildResult {
212
- errors: Message[];
213
- warnings: Message[];
214
+ export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
215
+ errors: Message[]
216
+ warnings: Message[]
214
217
  /** Only when "write: false" */
215
- outputFiles?: OutputFile[];
216
- /** Only when "incremental: true" */
217
- rebuild?: BuildInvalidate;
218
- /** Only when "watch: true" */
219
- stop?: () => void;
218
+ outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
220
219
  /** Only when "metafile: true" */
221
- metafile?: Metafile;
220
+ metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
222
221
  /** Only when "mangleCache" is present */
223
- mangleCache?: Record<string, string | false>;
222
+ mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
224
223
  }
225
224
 
226
225
  export interface BuildFailure extends Error {
227
- errors: Message[];
228
- warnings: Message[];
226
+ errors: Message[]
227
+ warnings: Message[]
229
228
  }
230
229
 
231
230
  /** Documentation: https://esbuild.github.io/api/#serve-arguments */
232
231
  export interface ServeOptions {
233
- port?: number;
234
- host?: string;
235
- servedir?: string;
236
- onRequest?: (args: ServeOnRequestArgs) => void;
232
+ port?: number
233
+ host?: string
234
+ servedir?: string
235
+ keyfile?: string
236
+ certfile?: string
237
+ onRequest?: (args: ServeOnRequestArgs) => void
237
238
  }
238
239
 
239
240
  export interface ServeOnRequestArgs {
240
- remoteAddress: string;
241
- method: string;
242
- path: string;
243
- status: number;
241
+ remoteAddress: string
242
+ method: string
243
+ path: string
244
+ status: number
244
245
  /** The time to generate the response, not to send it */
245
- timeInMS: number;
246
+ timeInMS: number
246
247
  }
247
248
 
248
249
  /** Documentation: https://esbuild.github.io/api/#serve-return-values */
249
250
  export interface ServeResult {
250
- port: number;
251
- host: string;
252
- wait: Promise<void>;
253
- stop: () => void;
251
+ port: number
252
+ host: string
254
253
  }
255
254
 
256
255
  export interface TransformOptions extends CommonOptions {
257
- tsconfigRaw?: string | {
258
- compilerOptions?: {
259
- alwaysStrict?: boolean,
260
- importsNotUsedAsValues?: 'remove' | 'preserve' | 'error',
261
- jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve',
262
- jsxFactory?: string,
263
- jsxFragmentFactory?: string,
264
- jsxImportSource?: string,
265
- preserveValueImports?: boolean,
266
- target?: string,
267
- useDefineForClassFields?: boolean,
268
- },
269
- };
270
-
271
- sourcefile?: string;
272
- loader?: Loader;
273
- banner?: string;
274
- footer?: string;
275
- }
276
-
277
- export interface TransformResult {
278
- code: string;
279
- map: string;
280
- warnings: Message[];
256
+ /** Documentation: https://esbuild.github.io/api/#sourcefile */
257
+ sourcefile?: string
258
+ /** Documentation: https://esbuild.github.io/api/#loader */
259
+ loader?: Loader
260
+ /** Documentation: https://esbuild.github.io/api/#banner */
261
+ banner?: string
262
+ /** Documentation: https://esbuild.github.io/api/#footer */
263
+ footer?: string
264
+ }
265
+
266
+ export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
267
+ code: string
268
+ map: string
269
+ warnings: Message[]
281
270
  /** Only when "mangleCache" is present */
282
- mangleCache?: Record<string, string | false>;
271
+ mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
283
272
  /** Only when "legalComments" is "external" */
284
- legalComments?: string;
273
+ legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
285
274
  }
286
275
 
287
276
  export interface TransformFailure extends Error {
288
- errors: Message[];
289
- warnings: Message[];
277
+ errors: Message[]
278
+ warnings: Message[]
290
279
  }
291
280
 
292
281
  export interface Plugin {
293
- name: string;
294
- setup: (build: PluginBuild) => (void | Promise<void>);
282
+ name: string
283
+ setup: (build: PluginBuild) => (void | Promise<void>)
295
284
  }
296
285
 
297
286
  export interface PluginBuild {
298
- initialOptions: BuildOptions;
299
- resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>;
287
+ /** Documentation: https://esbuild.github.io/plugins/#build-options */
288
+ initialOptions: BuildOptions
289
+
290
+ /** Documentation: https://esbuild.github.io/plugins/#resolve */
291
+ resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
300
292
 
293
+ /** Documentation: https://esbuild.github.io/plugins/#on-start */
301
294
  onStart(callback: () =>
302
- (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
295
+ (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
296
+
297
+ /** Documentation: https://esbuild.github.io/plugins/#on-end */
303
298
  onEnd(callback: (result: BuildResult) =>
304
- (void | Promise<void>)): void;
299
+ (OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
300
+
301
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve */
305
302
  onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
306
- (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;
303
+ (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
304
+
305
+ /** Documentation: https://esbuild.github.io/plugins/#on-load */
307
306
  onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
308
- (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void;
307
+ (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
308
+
309
+ /** Documentation: https://esbuild.github.io/plugins/#on-dispose */
310
+ onDispose(callback: () => void): void
309
311
 
310
312
  // This is a full copy of the esbuild library in case you need it
311
313
  esbuild: {
312
- serve: typeof serve,
314
+ context: typeof context,
313
315
  build: typeof build,
314
316
  buildSync: typeof buildSync,
315
317
  transform: typeof transform,
@@ -320,47 +322,56 @@ export interface PluginBuild {
320
322
  analyzeMetafileSync: typeof analyzeMetafileSync,
321
323
  initialize: typeof initialize,
322
324
  version: typeof version,
323
- };
325
+ }
324
326
  }
325
327
 
328
+ /** Documentation: https://esbuild.github.io/plugins/#resolve-options */
326
329
  export interface ResolveOptions {
327
- pluginName?: string;
328
- importer?: string;
329
- namespace?: string;
330
- resolveDir?: string;
331
- kind?: ImportKind;
332
- pluginData?: any;
330
+ pluginName?: string
331
+ importer?: string
332
+ namespace?: string
333
+ resolveDir?: string
334
+ kind?: ImportKind
335
+ pluginData?: any
333
336
  }
334
337
 
338
+ /** Documentation: https://esbuild.github.io/plugins/#resolve-results */
335
339
  export interface ResolveResult {
336
- errors: Message[];
337
- warnings: Message[];
340
+ errors: Message[]
341
+ warnings: Message[]
338
342
 
339
- path: string;
340
- external: boolean;
341
- sideEffects: boolean;
342
- namespace: string;
343
- suffix: string;
344
- pluginData: any;
343
+ path: string
344
+ external: boolean
345
+ sideEffects: boolean
346
+ namespace: string
347
+ suffix: string
348
+ pluginData: any
345
349
  }
346
350
 
347
351
  export interface OnStartResult {
348
- errors?: PartialMessage[];
349
- warnings?: PartialMessage[];
352
+ errors?: PartialMessage[]
353
+ warnings?: PartialMessage[]
354
+ }
355
+
356
+ export interface OnEndResult {
357
+ errors?: PartialMessage[]
358
+ warnings?: PartialMessage[]
350
359
  }
351
360
 
361
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
352
362
  export interface OnResolveOptions {
353
- filter: RegExp;
354
- namespace?: string;
363
+ filter: RegExp
364
+ namespace?: string
355
365
  }
356
366
 
367
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
357
368
  export interface OnResolveArgs {
358
- path: string;
359
- importer: string;
360
- namespace: string;
361
- resolveDir: string;
362
- kind: ImportKind;
363
- pluginData: any;
369
+ path: string
370
+ importer: string
371
+ namespace: string
372
+ resolveDir: string
373
+ kind: ImportKind
374
+ pluginData: any
364
375
  }
365
376
 
366
377
  export type ImportKind =
@@ -376,64 +387,69 @@ export type ImportKind =
376
387
  | 'import-rule'
377
388
  | 'url-token'
378
389
 
390
+ /** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
379
391
  export interface OnResolveResult {
380
- pluginName?: string;
392
+ pluginName?: string
381
393
 
382
- errors?: PartialMessage[];
383
- warnings?: PartialMessage[];
394
+ errors?: PartialMessage[]
395
+ warnings?: PartialMessage[]
384
396
 
385
- path?: string;
386
- external?: boolean;
387
- sideEffects?: boolean;
388
- namespace?: string;
389
- suffix?: string;
390
- pluginData?: any;
397
+ path?: string
398
+ external?: boolean
399
+ sideEffects?: boolean
400
+ namespace?: string
401
+ suffix?: string
402
+ pluginData?: any
391
403
 
392
- watchFiles?: string[];
393
- watchDirs?: string[];
404
+ watchFiles?: string[]
405
+ watchDirs?: string[]
394
406
  }
395
407
 
408
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-options */
396
409
  export interface OnLoadOptions {
397
- filter: RegExp;
398
- namespace?: string;
410
+ filter: RegExp
411
+ namespace?: string
399
412
  }
400
413
 
414
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
401
415
  export interface OnLoadArgs {
402
- path: string;
403
- namespace: string;
404
- suffix: string;
405
- pluginData: any;
416
+ path: string
417
+ namespace: string
418
+ suffix: string
419
+ pluginData: any
406
420
  }
407
421
 
422
+ /** Documentation: https://esbuild.github.io/plugins/#on-load-results */
408
423
  export interface OnLoadResult {
409
- pluginName?: string;
424
+ pluginName?: string
410
425
 
411
- errors?: PartialMessage[];
412
- warnings?: PartialMessage[];
426
+ errors?: PartialMessage[]
427
+ warnings?: PartialMessage[]
413
428
 
414
- contents?: string | Uint8Array;
415
- resolveDir?: string;
416
- loader?: Loader;
417
- pluginData?: any;
429
+ contents?: string | Uint8Array
430
+ resolveDir?: string
431
+ loader?: Loader
432
+ pluginData?: any
418
433
 
419
- watchFiles?: string[];
420
- watchDirs?: string[];
434
+ watchFiles?: string[]
435
+ watchDirs?: string[]
421
436
  }
422
437
 
423
438
  export interface PartialMessage {
424
- id?: string;
425
- pluginName?: string;
426
- text?: string;
427
- location?: Partial<Location> | null;
428
- notes?: PartialNote[];
429
- detail?: any;
439
+ id?: string
440
+ pluginName?: string
441
+ text?: string
442
+ location?: Partial<Location> | null
443
+ notes?: PartialNote[]
444
+ detail?: any
430
445
  }
431
446
 
432
447
  export interface PartialNote {
433
- text?: string;
434
- location?: Partial<Location> | null;
448
+ text?: string
449
+ location?: Partial<Location> | null
435
450
  }
436
451
 
452
+ /** Documentation: https://esbuild.github.io/api/#metafile */
437
453
  export interface Metafile {
438
454
  inputs: {
439
455
  [path: string]: {
@@ -468,16 +484,38 @@ export interface Metafile {
468
484
  }
469
485
 
470
486
  export interface FormatMessagesOptions {
471
- kind: 'error' | 'warning';
472
- color?: boolean;
473
- terminalWidth?: number;
487
+ kind: 'error' | 'warning'
488
+ color?: boolean
489
+ terminalWidth?: number
474
490
  }
475
491
 
476
492
  export interface AnalyzeMetafileOptions {
477
- color?: boolean;
478
- verbose?: boolean;
493
+ color?: boolean
494
+ verbose?: boolean
479
495
  }
480
496
 
497
+ export interface WatchOptions {
498
+ }
499
+
500
+ export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
501
+ /** Documentation: https://esbuild.github.io/api/#rebuild */
502
+ rebuild(): Promise<BuildResult<ProvidedOptions>>
503
+
504
+ /** Documentation: https://esbuild.github.io/api/#watch */
505
+ watch(options?: WatchOptions): Promise<void>
506
+
507
+ /** Documentation: https://esbuild.github.io/api/#serve */
508
+ serve(options?: ServeOptions): Promise<ServeResult>
509
+
510
+ cancel(): Promise<void>
511
+ dispose(): Promise<void>
512
+ }
513
+
514
+ // This is a TypeScript type-level function which replaces any keys in "In"
515
+ // that aren't in "Out" with "never". We use this to reject properties with
516
+ // typos in object literals. See: https://stackoverflow.com/questions/49580725
517
+ type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
518
+
481
519
  /**
482
520
  * This function invokes the "esbuild" command-line tool for you. It returns a
483
521
  * promise that either resolves with a "BuildResult" object or rejects with a
@@ -486,24 +524,20 @@ export interface AnalyzeMetafileOptions {
486
524
  * - Works in node: yes
487
525
  * - Works in browser: yes
488
526
  *
489
- * Documentation: https://esbuild.github.io/api/#build-api
527
+ * Documentation: https://esbuild.github.io/api/#build
490
528
  */
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>;
529
+ export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
496
530
 
497
531
  /**
498
- * This function is similar to "build" but it serves the resulting files over
499
- * HTTP on a localhost address with the specified port.
532
+ * This is the advanced long-running form of "build" that supports additional
533
+ * features such as watch mode and a local development server.
500
534
  *
501
535
  * - Works in node: yes
502
536
  * - Works in browser: no
503
537
  *
504
- * Documentation: https://esbuild.github.io/api/#serve
538
+ * Documentation: https://esbuild.github.io/api/#build
505
539
  */
506
- export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise<ServeResult>;
540
+ export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
507
541
 
508
542
  /**
509
543
  * This function transforms a single JavaScript file. It can be used to minify
@@ -514,9 +548,9 @@ export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOpt
514
548
  * - Works in node: yes
515
549
  * - Works in browser: yes
516
550
  *
517
- * Documentation: https://esbuild.github.io/api/#transform-api
551
+ * Documentation: https://esbuild.github.io/api/#transform
518
552
  */
519
- export declare function transform(input: string | Uint8Array, options?: TransformOptions): Promise<TransformResult>;
553
+ export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
520
554
 
521
555
  /**
522
556
  * Converts log messages to formatted message strings suitable for printing in
@@ -526,7 +560,7 @@ export declare function transform(input: string | Uint8Array, options?: Transfor
526
560
  * - Works in node: yes
527
561
  * - Works in browser: yes
528
562
  */
529
- export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
563
+ export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
530
564
 
531
565
  /**
532
566
  * Pretty-prints an analysis of the metafile JSON to a string. This is just for
@@ -538,7 +572,7 @@ export declare function formatMessages(messages: PartialMessage[], options: Form
538
572
  *
539
573
  * Documentation: https://esbuild.github.io/api/#analyze
540
574
  */
541
- export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>;
575
+ export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
542
576
 
543
577
  /**
544
578
  * A synchronous version of "build".
@@ -546,10 +580,9 @@ export declare function analyzeMetafile(metafile: Metafile | string, options?: A
546
580
  * - Works in node: yes
547
581
  * - Works in browser: no
548
582
  *
549
- * Documentation: https://esbuild.github.io/api/#build-api
583
+ * Documentation: https://esbuild.github.io/api/#build
550
584
  */
551
- export declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] };
552
- export declare function buildSync(options: BuildOptions): BuildResult;
585
+ export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
553
586
 
554
587
  /**
555
588
  * A synchronous version of "transform".
@@ -557,9 +590,9 @@ export declare function buildSync(options: BuildOptions): BuildResult;
557
590
  * - Works in node: yes
558
591
  * - Works in browser: no
559
592
  *
560
- * Documentation: https://esbuild.github.io/api/#transform-api
593
+ * Documentation: https://esbuild.github.io/api/#transform
561
594
  */
562
- export declare function transformSync(input: string, options?: TransformOptions): TransformResult;
595
+ export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
563
596
 
564
597
  /**
565
598
  * A synchronous version of "formatMessages".
@@ -567,7 +600,7 @@ export declare function transformSync(input: string, options?: TransformOptions)
567
600
  * - Works in node: yes
568
601
  * - Works in browser: no
569
602
  */
570
- export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
603
+ export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
571
604
 
572
605
  /**
573
606
  * A synchronous version of "analyzeMetafile".
@@ -577,7 +610,7 @@ export declare function formatMessagesSync(messages: PartialMessage[], options:
577
610
  *
578
611
  * Documentation: https://esbuild.github.io/api/#analyze
579
612
  */
580
- export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string;
613
+ export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
581
614
 
582
615
  /**
583
616
  * This configures the browser-based version of esbuild. It is necessary to
@@ -587,9 +620,9 @@ export declare function analyzeMetafileSync(metafile: Metafile | string, options
587
620
  * - Works in node: yes
588
621
  * - Works in browser: yes ("options" is required)
589
622
  *
590
- * Documentation: https://esbuild.github.io/api/#running-in-the-browser
623
+ * Documentation: https://esbuild.github.io/api/#browser
591
624
  */
592
- export declare function initialize(options: InitializeOptions): Promise<void>;
625
+ export declare function initialize(options: InitializeOptions): Promise<void>
593
626
 
594
627
  export interface InitializeOptions {
595
628
  /**
@@ -616,4 +649,4 @@ export interface InitializeOptions {
616
649
  worker?: boolean
617
650
  }
618
651
 
619
- export let version: string;
652
+ export let version: string