main.d.ts 21 KB

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