<type>api
/

dist/esm/index.d.mts

Types
  • FilePath

    type FilePath = string;
  • GlobOptions

    type GlobOptions = {
        cwd?: string;
        dot?: boolean;
        absolute?: boolean;
        filesOnly?: boolean;
        flush?: boolean;
    };
Functions
  • createContext

    declare function createContext(initial: esbuild.BuildOptions): ContextManager;
All
import esbuild from 'esbuild';

type FilePath = string;
type GlobOptions = {
    cwd?: string;
    dot?: boolean;
    absolute?: boolean;
    filesOnly?: boolean;
    flush?: boolean;
};
declare const CONSTANTS: {
    ERROR: string;
    BUILD_COMPLETE: string;
    WATCH_COMPLETE: string;
    BUILD_ERROR: string;
    WATCH_ERROR: string;
};
declare class ContextManager {
    #private;
    initialConfig: esbuild.BuildOptions;
    constructor(initial: esbuild.BuildOptions);
    hook(eventName: any, handler: any): () => void;
    getConfig(name: string): {
        name: string;
        config: esbuild.BuildOptions;
    };
    getAllConfigs(): {
        name: string;
        config: esbuild.BuildOptions;
    }[];
    /**
     * returns the raw esbuild context to be used
     * externally from the multicontext environment
     *
     * this will not fire any of the hooks or report rebuilds
     * please avoid using this unless you wish to manage the context
     * manually
     * @param name
     * @returns
     */
    getContext(name: string): false | Promise<any>;
    add(name: string, conf: esbuild.BuildOptions): void;
    glob(pattern: string, opts: GlobOptions): Promise<FilePath[]>;
    /**
     * @param {object} options
     * @param {string} options.name - experimental
     * @param {number} options.limit
     *
     * @description run a certain number of builds at once to avoid heavy usage of memory
     * esbuild itself is fast so this doesn't take much time but if there's cases where it's hanging up your system,
     * then use the `limit` option to set an execution window
     *
     * example: if limit is 1, one build is run at most at a time
     * if limit is 3, at any given time 3 builds would be running.
     *
     * **Note**: This option makes no sense unless you usecase handles over 10+ context instances
     */
    build({ name, limit }?: {
        name?: string;
        limit?: number;
    }): Promise<void>;
    /**
     * @param {object} options
     * @param {number} options.limit
     *
     * @description run a certain number of watchers at once to avoid heavy usage of memory
     * esbuild itself is fast so this doesn't take much time but if there's cases where it's hanging up your system,
     * then use the `limit` option to set an execution window
     *
     * example: if limit is 1, one build is run at most at a time
     * if limit is 3, at any given time 3 watchers would be running.
     *
     * **Note**: This option makes no sense unless you usecase handles over 10+ context instances
     */
    watch({ limit }?: {
        limit?: number;
    }): Promise<void>;
    dispose(): Promise<void>;
}

declare function createContext(initial: esbuild.BuildOptions): ContextManager;

export { CONSTANTS, createContext };

dist/esm/watcher.d.mts

Types
  • WatchEvent

    type WatchEvent = {
        type: string;
        file: string;
    };
  • Options

    type Options = {
        root?: string;
        onBuild?(): void | Promise<void>;
        onEvent?(event: WatchEvent): boolean;
    };
Interfaces
  • ContextRebuilder

    interface ContextRebuilder {
        build(...args: unknown[]): unknown | Promise<unknown>;
    }
Functions
  • createContextWatcher

    declare const createContextWatcher: (context: ContextRebuilder) => (globPattern: any, { root, onEvent, onBuild }?: Options) => void;
All
type WatchEvent = {
    type: string;
    file: string;
};
type Options = {
    root?: string;
    onBuild?(): void | Promise<void>;
    onEvent?(event: WatchEvent): boolean;
};
interface ContextRebuilder {
    build(...args: unknown[]): unknown | Promise<unknown>;
}
declare const createContextWatcher: (context: ContextRebuilder) => (globPattern: any, { root, onEvent, onBuild }?: Options) => void;

export { type ContextRebuilder, type Options, type WatchEvent, createContextWatcher };

dist/cjs/index.d.cts

Types
  • FilePath

    type FilePath = string;
  • GlobOptions

    type GlobOptions = {
        cwd?: string;
        dot?: boolean;
        absolute?: boolean;
        filesOnly?: boolean;
        flush?: boolean;
    };
Functions
  • createContext

    declare function createContext(initial: esbuild.BuildOptions): ContextManager;
All
import esbuild from 'esbuild';

type FilePath = string;
type GlobOptions = {
    cwd?: string;
    dot?: boolean;
    absolute?: boolean;
    filesOnly?: boolean;
    flush?: boolean;
};
declare const CONSTANTS: {
    ERROR: string;
    BUILD_COMPLETE: string;
    WATCH_COMPLETE: string;
    BUILD_ERROR: string;
    WATCH_ERROR: string;
};
declare class ContextManager {
    #private;
    initialConfig: esbuild.BuildOptions;
    constructor(initial: esbuild.BuildOptions);
    hook(eventName: any, handler: any): () => void;
    getConfig(name: string): {
        name: string;
        config: esbuild.BuildOptions;
    };
    getAllConfigs(): {
        name: string;
        config: esbuild.BuildOptions;
    }[];
    /**
     * returns the raw esbuild context to be used
     * externally from the multicontext environment
     *
     * this will not fire any of the hooks or report rebuilds
     * please avoid using this unless you wish to manage the context
     * manually
     * @param name
     * @returns
     */
    getContext(name: string): false | Promise<any>;
    add(name: string, conf: esbuild.BuildOptions): void;
    glob(pattern: string, opts: GlobOptions): Promise<FilePath[]>;
    /**
     * @param {object} options
     * @param {string} options.name - experimental
     * @param {number} options.limit
     *
     * @description run a certain number of builds at once to avoid heavy usage of memory
     * esbuild itself is fast so this doesn't take much time but if there's cases where it's hanging up your system,
     * then use the `limit` option to set an execution window
     *
     * example: if limit is 1, one build is run at most at a time
     * if limit is 3, at any given time 3 builds would be running.
     *
     * **Note**: This option makes no sense unless you usecase handles over 10+ context instances
     */
    build({ name, limit }?: {
        name?: string;
        limit?: number;
    }): Promise<void>;
    /**
     * @param {object} options
     * @param {number} options.limit
     *
     * @description run a certain number of watchers at once to avoid heavy usage of memory
     * esbuild itself is fast so this doesn't take much time but if there's cases where it's hanging up your system,
     * then use the `limit` option to set an execution window
     *
     * example: if limit is 1, one build is run at most at a time
     * if limit is 3, at any given time 3 watchers would be running.
     *
     * **Note**: This option makes no sense unless you usecase handles over 10+ context instances
     */
    watch({ limit }?: {
        limit?: number;
    }): Promise<void>;
    dispose(): Promise<void>;
}

declare function createContext(initial: esbuild.BuildOptions): ContextManager;

export { CONSTANTS, createContext };

dist/cjs/watcher.d.cts

Types
  • WatchEvent

    type WatchEvent = {
        type: string;
        file: string;
    };
  • Options

    type Options = {
        root?: string;
        onBuild?(): void | Promise<void>;
        onEvent?(event: WatchEvent): boolean;
    };
Interfaces
  • ContextRebuilder

    interface ContextRebuilder {
        build(...args: unknown[]): unknown | Promise<unknown>;
    }
Functions
  • createContextWatcher

    declare const createContextWatcher: (context: ContextRebuilder) => (globPattern: any, { root, onEvent, onBuild }?: Options) => void;
All
type WatchEvent = {
    type: string;
    file: string;
};
type Options = {
    root?: string;
    onBuild?(): void | Promise<void>;
    onEvent?(event: WatchEvent): boolean;
};
interface ContextRebuilder {
    build(...args: unknown[]): unknown | Promise<unknown>;
}
declare const createContextWatcher: (context: ContextRebuilder) => (globPattern: any, { root, onEvent, onBuild }?: Options) => void;

export { type ContextRebuilder, type Options, type WatchEvent, createContextWatcher };