Skip to content

Commit

Permalink
fix: update esbuild types
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Aug 6, 2024
1 parent 2b5be38 commit 334f560
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/config/npm/esbuild.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
* @see https://www.npmjs.com/package/esbuild?activeTab=code
*/

export type Platform = 'browser' | 'node' | 'neutral'
export type Format = 'iife' | 'cjs' | 'esm'
export type Loader =
Expand Down Expand Up @@ -146,7 +145,7 @@ export interface BuildOptions extends CommonOptions {
/** Documentation: https://esbuild.github.io/api/#external */
external?: string[]
/** Documentation: https://esbuild.github.io/api/#packages */
packages?: 'external'
packages?: 'bundle' | 'external'
/** Documentation: https://esbuild.github.io/api/#alias */
alias?: Record<string, string>
/** Documentation: https://esbuild.github.io/api/#loader */
Expand Down Expand Up @@ -375,6 +374,7 @@ export interface ResolveOptions {
resolveDir?: string
kind?: ImportKind
pluginData?: any
with?: Record<string, string>
}

/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
Expand Down Expand Up @@ -414,6 +414,7 @@ export interface OnResolveArgs {
resolveDir: string
kind: ImportKind
pluginData: any
with: Record<string, string>
}

export type ImportKind =
Expand Down Expand Up @@ -460,6 +461,7 @@ export interface OnLoadArgs {
namespace: string
suffix: string
pluginData: any
with: Record<string, string>
}

/** Documentation: https://esbuild.github.io/plugins/#on-load-results */
Expand Down Expand Up @@ -502,8 +504,10 @@ export interface Metafile {
kind: ImportKind
external?: boolean
original?: string
with?: Record<string, string>
}[]
format?: 'cjs' | 'esm'
with?: Record<string, string>
}
}
outputs: {
Expand Down Expand Up @@ -716,3 +720,41 @@ export interface InitializeOptions {
}

export const version: string

// Call this function to terminate esbuild's child process. The child process
// is not terminated and re-created after each API call because it's more
// efficient to keep it around when there are multiple API calls.
//
// In node this happens automatically before the parent node process exits. So
// you only need to call this if you know you will not make any more esbuild
// API calls and you want to clean up resources.
//
// Unlike node, Deno lacks the necessary APIs to clean up child processes
// automatically. You must manually call stop() in Deno when you're done
// using esbuild or Deno will continue running forever.
//
// Another reason you might want to call this is if you are using esbuild from
// within a Deno test. Deno fails tests that create a child process without
// killing it before the test ends, so you have to call this function (and
// await the returned promise) in every Deno test that uses esbuild.
export declare function stop(): Promise<void>

// Note: These declarations exist to avoid type errors when you omit "dom" from
// "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
// global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
// with the browser DOM and is present in many non-browser JavaScript runtimes
// (e.g. node and deno). Declaring it here allows esbuild's API to be used in
// these scenarios.
//
// There's an open issue about getting this problem corrected (although these
// declarations will need to remain even if this is fixed for backward
// compatibility with older TypeScript versions):
//
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
//
declare global {
namespace WebAssembly {
interface Module {}
}
interface URL {}
}

0 comments on commit 334f560

Please sign in to comment.