import { SupportedCDNS } from 'cdn-resolve';
import { Loader, OnResolveArgs, PluginBuild, Plugin } from 'esbuild';

interface Options {
    /**
     * The CDN to use for resolving imports.
     * @default "esm"
     */
    cdn?: SupportedCDNS;
    /**
     * Exclude certain packages from being resolved by the CDN.
     */
    exclude?: string[];
    /**
     * Versions to use for certain packages.
     */
    versions?: Record<string, string>;
    /**
     * The default loader to use for files, that doesn't have a file extension
     * @default js
     */
    defaultLoader?: Loader;
    /**
     * A callback that is called when a relative import is encountered.
     * @param {OnResolveArgs} args The arguments passed to the `onResolve` callback.
     * @param {PluginBuild} build The `PluginBuild` instance.
     * @returns {ReturnType<Parameters<PluginBuild["onResolve"]>[1]>} The result of the `onResolve` callback.
     */
    relativeImportsHandler?: (args: OnResolveArgs, build: PluginBuild) => ReturnType<Parameters<PluginBuild["onResolve"]>[1]>;
    /**
     * Use jsdelivr ESM for resolving imports.
     * @default true
     */
    useJsdelivrEsm?: boolean;
    /**
     * Enable debug logging
     * @default false
     */
    debug?: boolean;
}
declare function CDNImports(options?: Options): Plugin;

export { CDNImports, type Options };
