main.d.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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' | 'local-css' | '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. interface CommonOptions {
  8. /** Documentation: https://esbuild.github.io/api/#sourcemap */
  9. sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'
  10. /** Documentation: https://esbuild.github.io/api/#legal-comments */
  11. legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'
  12. /** Documentation: https://esbuild.github.io/api/#source-root */
  13. sourceRoot?: string
  14. /** Documentation: https://esbuild.github.io/api/#sources-content */
  15. sourcesContent?: boolean
  16. /** Documentation: https://esbuild.github.io/api/#format */
  17. format?: Format
  18. /** Documentation: https://esbuild.github.io/api/#global-name */
  19. globalName?: string
  20. /** Documentation: https://esbuild.github.io/api/#target */
  21. target?: string | string[]
  22. /** Documentation: https://esbuild.github.io/api/#supported */
  23. supported?: Record<string, boolean>
  24. /** Documentation: https://esbuild.github.io/api/#platform */
  25. platform?: Platform
  26. /** Documentation: https://esbuild.github.io/api/#mangle-props */
  27. mangleProps?: RegExp
  28. /** Documentation: https://esbuild.github.io/api/#mangle-props */
  29. reserveProps?: RegExp
  30. /** Documentation: https://esbuild.github.io/api/#mangle-props */
  31. mangleQuoted?: boolean
  32. /** Documentation: https://esbuild.github.io/api/#mangle-props */
  33. mangleCache?: Record<string, string | false>
  34. /** Documentation: https://esbuild.github.io/api/#drop */
  35. drop?: Drop[]
  36. /** Documentation: https://esbuild.github.io/api/#drop-labels */
  37. dropLabels?: string[]
  38. /** Documentation: https://esbuild.github.io/api/#minify */
  39. minify?: boolean
  40. /** Documentation: https://esbuild.github.io/api/#minify */
  41. minifyWhitespace?: boolean
  42. /** Documentation: https://esbuild.github.io/api/#minify */
  43. minifyIdentifiers?: boolean
  44. /** Documentation: https://esbuild.github.io/api/#minify */
  45. minifySyntax?: boolean
  46. /** Documentation: https://esbuild.github.io/api/#line-limit */
  47. lineLimit?: number
  48. /** Documentation: https://esbuild.github.io/api/#charset */
  49. charset?: Charset
  50. /** Documentation: https://esbuild.github.io/api/#tree-shaking */
  51. treeShaking?: boolean
  52. /** Documentation: https://esbuild.github.io/api/#ignore-annotations */
  53. ignoreAnnotations?: boolean
  54. /** Documentation: https://esbuild.github.io/api/#jsx */
  55. jsx?: 'transform' | 'preserve' | 'automatic'
  56. /** Documentation: https://esbuild.github.io/api/#jsx-factory */
  57. jsxFactory?: string
  58. /** Documentation: https://esbuild.github.io/api/#jsx-fragment */
  59. jsxFragment?: string
  60. /** Documentation: https://esbuild.github.io/api/#jsx-import-source */
  61. jsxImportSource?: string
  62. /** Documentation: https://esbuild.github.io/api/#jsx-development */
  63. jsxDev?: boolean
  64. /** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
  65. jsxSideEffects?: boolean
  66. /** Documentation: https://esbuild.github.io/api/#define */
  67. define?: { [key: string]: string }
  68. /** Documentation: https://esbuild.github.io/api/#pure */
  69. pure?: string[]
  70. /** Documentation: https://esbuild.github.io/api/#keep-names */
  71. keepNames?: boolean
  72. /** Documentation: https://esbuild.github.io/api/#color */
  73. color?: boolean
  74. /** Documentation: https://esbuild.github.io/api/#log-level */
  75. logLevel?: LogLevel
  76. /** Documentation: https://esbuild.github.io/api/#log-limit */
  77. logLimit?: number
  78. /** Documentation: https://esbuild.github.io/api/#log-override */
  79. logOverride?: Record<string, LogLevel>
  80. /** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
  81. tsconfigRaw?: string | TsconfigRaw
  82. }
  83. export interface TsconfigRaw {
  84. compilerOptions?: {
  85. alwaysStrict?: boolean
  86. baseUrl?: boolean
  87. experimentalDecorators?: boolean
  88. importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
  89. jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
  90. jsxFactory?: string
  91. jsxFragmentFactory?: string
  92. jsxImportSource?: string
  93. paths?: Record<string, string[]>
  94. preserveValueImports?: boolean
  95. strict?: boolean
  96. target?: string
  97. useDefineForClassFields?: boolean
  98. verbatimModuleSyntax?: boolean
  99. }
  100. }
  101. export interface BuildOptions extends CommonOptions {
  102. /** Documentation: https://esbuild.github.io/api/#bundle */
  103. bundle?: boolean
  104. /** Documentation: https://esbuild.github.io/api/#splitting */
  105. splitting?: boolean
  106. /** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
  107. preserveSymlinks?: boolean
  108. /** Documentation: https://esbuild.github.io/api/#outfile */
  109. outfile?: string
  110. /** Documentation: https://esbuild.github.io/api/#metafile */
  111. metafile?: boolean
  112. /** Documentation: https://esbuild.github.io/api/#outdir */
  113. outdir?: string
  114. /** Documentation: https://esbuild.github.io/api/#outbase */
  115. outbase?: string
  116. /** Documentation: https://esbuild.github.io/api/#external */
  117. external?: string[]
  118. /** Documentation: https://esbuild.github.io/api/#packages */
  119. packages?: 'external'
  120. /** Documentation: https://esbuild.github.io/api/#alias */
  121. alias?: Record<string, string>
  122. /** Documentation: https://esbuild.github.io/api/#loader */
  123. loader?: { [ext: string]: Loader }
  124. /** Documentation: https://esbuild.github.io/api/#resolve-extensions */
  125. resolveExtensions?: string[]
  126. /** Documentation: https://esbuild.github.io/api/#main-fields */
  127. mainFields?: string[]
  128. /** Documentation: https://esbuild.github.io/api/#conditions */
  129. conditions?: string[]
  130. /** Documentation: https://esbuild.github.io/api/#write */
  131. write?: boolean
  132. /** Documentation: https://esbuild.github.io/api/#allow-overwrite */
  133. allowOverwrite?: boolean
  134. /** Documentation: https://esbuild.github.io/api/#tsconfig */
  135. tsconfig?: string
  136. /** Documentation: https://esbuild.github.io/api/#out-extension */
  137. outExtension?: { [ext: string]: string }
  138. /** Documentation: https://esbuild.github.io/api/#public-path */
  139. publicPath?: string
  140. /** Documentation: https://esbuild.github.io/api/#entry-names */
  141. entryNames?: string
  142. /** Documentation: https://esbuild.github.io/api/#chunk-names */
  143. chunkNames?: string
  144. /** Documentation: https://esbuild.github.io/api/#asset-names */
  145. assetNames?: string
  146. /** Documentation: https://esbuild.github.io/api/#inject */
  147. inject?: string[]
  148. /** Documentation: https://esbuild.github.io/api/#banner */
  149. banner?: { [type: string]: string }
  150. /** Documentation: https://esbuild.github.io/api/#footer */
  151. footer?: { [type: string]: string }
  152. /** Documentation: https://esbuild.github.io/api/#entry-points */
  153. entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
  154. /** Documentation: https://esbuild.github.io/api/#stdin */
  155. stdin?: StdinOptions
  156. /** Documentation: https://esbuild.github.io/plugins/ */
  157. plugins?: Plugin[]
  158. /** Documentation: https://esbuild.github.io/api/#working-directory */
  159. absWorkingDir?: string
  160. /** Documentation: https://esbuild.github.io/api/#node-paths */
  161. nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
  162. }
  163. export interface StdinOptions {
  164. contents: string | Uint8Array
  165. resolveDir?: string
  166. sourcefile?: string
  167. loader?: Loader
  168. }
  169. export interface Message {
  170. id: string
  171. pluginName: string
  172. text: string
  173. location: Location | null
  174. notes: Note[]
  175. /**
  176. * Optional user-specified data that is passed through unmodified. You can
  177. * use this to stash the original error, for example.
  178. */
  179. detail: any
  180. }
  181. export interface Note {
  182. text: string
  183. location: Location | null
  184. }
  185. export interface Location {
  186. file: string
  187. namespace: string
  188. /** 1-based */
  189. line: number
  190. /** 0-based, in bytes */
  191. column: number
  192. /** in bytes */
  193. length: number
  194. lineText: string
  195. suggestion: string
  196. }
  197. export interface OutputFile {
  198. path: string
  199. contents: Uint8Array
  200. hash: string
  201. /** "contents" as text (changes automatically with "contents") */
  202. readonly text: string
  203. }
  204. export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
  205. errors: Message[]
  206. warnings: Message[]
  207. /** Only when "write: false" */
  208. outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
  209. /** Only when "metafile: true" */
  210. metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
  211. /** Only when "mangleCache" is present */
  212. mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
  213. }
  214. export interface BuildFailure extends Error {
  215. errors: Message[]
  216. warnings: Message[]
  217. }
  218. /** Documentation: https://esbuild.github.io/api/#serve-arguments */
  219. export interface ServeOptions {
  220. port?: number
  221. host?: string
  222. servedir?: string
  223. keyfile?: string
  224. certfile?: string
  225. fallback?: string
  226. onRequest?: (args: ServeOnRequestArgs) => void
  227. }
  228. export interface ServeOnRequestArgs {
  229. remoteAddress: string
  230. method: string
  231. path: string
  232. status: number
  233. /** The time to generate the response, not to send it */
  234. timeInMS: number
  235. }
  236. /** Documentation: https://esbuild.github.io/api/#serve-return-values */
  237. export interface ServeResult {
  238. port: number
  239. host: string
  240. }
  241. export interface TransformOptions extends CommonOptions {
  242. /** Documentation: https://esbuild.github.io/api/#sourcefile */
  243. sourcefile?: string
  244. /** Documentation: https://esbuild.github.io/api/#loader */
  245. loader?: Loader
  246. /** Documentation: https://esbuild.github.io/api/#banner */
  247. banner?: string
  248. /** Documentation: https://esbuild.github.io/api/#footer */
  249. footer?: string
  250. }
  251. export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
  252. code: string
  253. map: string
  254. warnings: Message[]
  255. /** Only when "mangleCache" is present */
  256. mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
  257. /** Only when "legalComments" is "external" */
  258. legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
  259. }
  260. export interface TransformFailure extends Error {
  261. errors: Message[]
  262. warnings: Message[]
  263. }
  264. export interface Plugin {
  265. name: string
  266. setup: (build: PluginBuild) => (void | Promise<void>)
  267. }
  268. export interface PluginBuild {
  269. /** Documentation: https://esbuild.github.io/plugins/#build-options */
  270. initialOptions: BuildOptions
  271. /** Documentation: https://esbuild.github.io/plugins/#resolve */
  272. resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
  273. /** Documentation: https://esbuild.github.io/plugins/#on-start */
  274. onStart(callback: () =>
  275. (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
  276. /** Documentation: https://esbuild.github.io/plugins/#on-end */
  277. onEnd(callback: (result: BuildResult) =>
  278. (OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
  279. /** Documentation: https://esbuild.github.io/plugins/#on-resolve */
  280. onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
  281. (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
  282. /** Documentation: https://esbuild.github.io/plugins/#on-load */
  283. onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
  284. (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
  285. /** Documentation: https://esbuild.github.io/plugins/#on-dispose */
  286. onDispose(callback: () => void): void
  287. // This is a full copy of the esbuild library in case you need it
  288. esbuild: {
  289. context: typeof context,
  290. build: typeof build,
  291. buildSync: typeof buildSync,
  292. transform: typeof transform,
  293. transformSync: typeof transformSync,
  294. formatMessages: typeof formatMessages,
  295. formatMessagesSync: typeof formatMessagesSync,
  296. analyzeMetafile: typeof analyzeMetafile,
  297. analyzeMetafileSync: typeof analyzeMetafileSync,
  298. initialize: typeof initialize,
  299. version: typeof version,
  300. }
  301. }
  302. /** Documentation: https://esbuild.github.io/plugins/#resolve-options */
  303. export interface ResolveOptions {
  304. pluginName?: string
  305. importer?: string
  306. namespace?: string
  307. resolveDir?: string
  308. kind?: ImportKind
  309. pluginData?: any
  310. }
  311. /** Documentation: https://esbuild.github.io/plugins/#resolve-results */
  312. export interface ResolveResult {
  313. errors: Message[]
  314. warnings: Message[]
  315. path: string
  316. external: boolean
  317. sideEffects: boolean
  318. namespace: string
  319. suffix: string
  320. pluginData: any
  321. }
  322. export interface OnStartResult {
  323. errors?: PartialMessage[]
  324. warnings?: PartialMessage[]
  325. }
  326. export interface OnEndResult {
  327. errors?: PartialMessage[]
  328. warnings?: PartialMessage[]
  329. }
  330. /** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
  331. export interface OnResolveOptions {
  332. filter: RegExp
  333. namespace?: string
  334. }
  335. /** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
  336. export interface OnResolveArgs {
  337. path: string
  338. importer: string
  339. namespace: string
  340. resolveDir: string
  341. kind: ImportKind
  342. pluginData: any
  343. }
  344. export type ImportKind =
  345. | 'entry-point'
  346. // JS
  347. | 'import-statement'
  348. | 'require-call'
  349. | 'dynamic-import'
  350. | 'require-resolve'
  351. // CSS
  352. | 'import-rule'
  353. | 'composes-from'
  354. | 'url-token'
  355. /** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
  356. export interface OnResolveResult {
  357. pluginName?: string
  358. errors?: PartialMessage[]
  359. warnings?: PartialMessage[]
  360. path?: string
  361. external?: boolean
  362. sideEffects?: boolean
  363. namespace?: string
  364. suffix?: string
  365. pluginData?: any
  366. watchFiles?: string[]
  367. watchDirs?: string[]
  368. }
  369. /** Documentation: https://esbuild.github.io/plugins/#on-load-options */
  370. export interface OnLoadOptions {
  371. filter: RegExp
  372. namespace?: string
  373. }
  374. /** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
  375. export interface OnLoadArgs {
  376. path: string
  377. namespace: string
  378. suffix: string
  379. pluginData: any
  380. }
  381. /** Documentation: https://esbuild.github.io/plugins/#on-load-results */
  382. export interface OnLoadResult {
  383. pluginName?: string
  384. errors?: PartialMessage[]
  385. warnings?: PartialMessage[]
  386. contents?: string | Uint8Array
  387. resolveDir?: string
  388. loader?: Loader
  389. pluginData?: any
  390. watchFiles?: string[]
  391. watchDirs?: string[]
  392. }
  393. export interface PartialMessage {
  394. id?: string
  395. pluginName?: string
  396. text?: string
  397. location?: Partial<Location> | null
  398. notes?: PartialNote[]
  399. detail?: any
  400. }
  401. export interface PartialNote {
  402. text?: string
  403. location?: Partial<Location> | null
  404. }
  405. /** Documentation: https://esbuild.github.io/api/#metafile */
  406. export interface Metafile {
  407. inputs: {
  408. [path: string]: {
  409. bytes: number
  410. imports: {
  411. path: string
  412. kind: ImportKind
  413. external?: boolean
  414. original?: string
  415. }[]
  416. format?: 'cjs' | 'esm'
  417. }
  418. }
  419. outputs: {
  420. [path: string]: {
  421. bytes: number
  422. inputs: {
  423. [path: string]: {
  424. bytesInOutput: number
  425. }
  426. }
  427. imports: {
  428. path: string
  429. kind: ImportKind | 'file-loader'
  430. external?: boolean
  431. }[]
  432. exports: string[]
  433. entryPoint?: string
  434. cssBundle?: string
  435. }
  436. }
  437. }
  438. export interface FormatMessagesOptions {
  439. kind: 'error' | 'warning'
  440. color?: boolean
  441. terminalWidth?: number
  442. }
  443. export interface AnalyzeMetafileOptions {
  444. color?: boolean
  445. verbose?: boolean
  446. }
  447. export interface WatchOptions {
  448. }
  449. export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
  450. /** Documentation: https://esbuild.github.io/api/#rebuild */
  451. rebuild(): Promise<BuildResult<ProvidedOptions>>
  452. /** Documentation: https://esbuild.github.io/api/#watch */
  453. watch(options?: WatchOptions): Promise<void>
  454. /** Documentation: https://esbuild.github.io/api/#serve */
  455. serve(options?: ServeOptions): Promise<ServeResult>
  456. cancel(): Promise<void>
  457. dispose(): Promise<void>
  458. }
  459. // This is a TypeScript type-level function which replaces any keys in "In"
  460. // that aren't in "Out" with "never". We use this to reject properties with
  461. // typos in object literals. See: https://stackoverflow.com/questions/49580725
  462. type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
  463. /**
  464. * This function invokes the "esbuild" command-line tool for you. It returns a
  465. * promise that either resolves with a "BuildResult" object or rejects with a
  466. * "BuildFailure" object.
  467. *
  468. * - Works in node: yes
  469. * - Works in browser: yes
  470. *
  471. * Documentation: https://esbuild.github.io/api/#build
  472. */
  473. export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
  474. /**
  475. * This is the advanced long-running form of "build" that supports additional
  476. * features such as watch mode and a local development server.
  477. *
  478. * - Works in node: yes
  479. * - Works in browser: no
  480. *
  481. * Documentation: https://esbuild.github.io/api/#build
  482. */
  483. export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
  484. /**
  485. * This function transforms a single JavaScript file. It can be used to minify
  486. * JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
  487. * to older JavaScript. It returns a promise that is either resolved with a
  488. * "TransformResult" object or rejected with a "TransformFailure" object.
  489. *
  490. * - Works in node: yes
  491. * - Works in browser: yes
  492. *
  493. * Documentation: https://esbuild.github.io/api/#transform
  494. */
  495. export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
  496. /**
  497. * Converts log messages to formatted message strings suitable for printing in
  498. * the terminal. This allows you to reuse the built-in behavior of esbuild's
  499. * log message formatter. This is a batch-oriented API for efficiency.
  500. *
  501. * - Works in node: yes
  502. * - Works in browser: yes
  503. */
  504. export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
  505. /**
  506. * Pretty-prints an analysis of the metafile JSON to a string. This is just for
  507. * convenience to be able to match esbuild's pretty-printing exactly. If you want
  508. * to customize it, you can just inspect the data in the metafile yourself.
  509. *
  510. * - Works in node: yes
  511. * - Works in browser: yes
  512. *
  513. * Documentation: https://esbuild.github.io/api/#analyze
  514. */
  515. export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
  516. /**
  517. * A synchronous version of "build".
  518. *
  519. * - Works in node: yes
  520. * - Works in browser: no
  521. *
  522. * Documentation: https://esbuild.github.io/api/#build
  523. */
  524. export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
  525. /**
  526. * A synchronous version of "transform".
  527. *
  528. * - Works in node: yes
  529. * - Works in browser: no
  530. *
  531. * Documentation: https://esbuild.github.io/api/#transform
  532. */
  533. export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
  534. /**
  535. * A synchronous version of "formatMessages".
  536. *
  537. * - Works in node: yes
  538. * - Works in browser: no
  539. */
  540. export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
  541. /**
  542. * A synchronous version of "analyzeMetafile".
  543. *
  544. * - Works in node: yes
  545. * - Works in browser: no
  546. *
  547. * Documentation: https://esbuild.github.io/api/#analyze
  548. */
  549. export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
  550. /**
  551. * This configures the browser-based version of esbuild. It is necessary to
  552. * call this first and wait for the returned promise to be resolved before
  553. * making other API calls when using esbuild in the browser.
  554. *
  555. * - Works in node: yes
  556. * - Works in browser: yes ("options" is required)
  557. *
  558. * Documentation: https://esbuild.github.io/api/#browser
  559. */
  560. export declare function initialize(options: InitializeOptions): Promise<void>
  561. export interface InitializeOptions {
  562. /**
  563. * The URL of the "esbuild.wasm" file. This must be provided when running
  564. * esbuild in the browser.
  565. */
  566. wasmURL?: string | URL
  567. /**
  568. * The result of calling "new WebAssembly.Module(buffer)" where "buffer"
  569. * is a typed array or ArrayBuffer containing the binary code of the
  570. * "esbuild.wasm" file.
  571. *
  572. * You can use this as an alternative to "wasmURL" for environments where it's
  573. * not possible to download the WebAssembly module.
  574. */
  575. wasmModule?: WebAssembly.Module
  576. /**
  577. * By default esbuild runs the WebAssembly-based browser API in a web worker
  578. * to avoid blocking the UI thread. This can be disabled by setting "worker"
  579. * to false.
  580. */
  581. worker?: boolean
  582. }
  583. export let version: string