/** * Node/Bun/Deno bundler implementation using esbuild-wasm. * * This bundler uses the same WebAssembly-based esbuild as the browser bundler, * but runs in Node.js/Bun/Deno environments. It's primarily useful for: * * 1. Testing consistency with the browser bundler * 2. Ensuring identical import resolution behavior * 3. Validating that bundled output matches between browser and server * * For production use, prefer EsbuildNativeBundler which is ~3-5x faster. */ import type { IBundler, BundleOptions, BundleResult } from "../types"; export interface EsbuildWasmNodeBundlerOptions { /** * Base URL for CDN imports. * npm imports like "lodash" are rewritten to "{cdnBaseUrl}/lodash@{version}". * @default "https://esm.sh" */ cdnBaseUrl?: string; /** * ECMAScript target for esm.sh CDN imports. * * This sets the `?target=` query parameter on esm.sh URLs to ensure * consistent output. Without this, esm.sh uses User-Agent detection * which can vary between environments. * * @example "es2020" * @example "es2022" * @default "es2020" */ esmTarget?: string; } /** * Bundler implementation using esbuild-wasm for Node.js/Bun/Deno. * * Uses the same WebAssembly-based esbuild as the browser bundler, * making it ideal for testing consistency between browser and server builds. * * @example * ```ts * const bundler = new EsbuildWasmNodeBundler(); * await bundler.initialize(); * * const result = await bundler.bundle({ * fs: myFilesystem, * entryPoint: "/src/index.ts", * }); * ``` * * @example Testing consistency with native bundler * ```ts * const native = new EsbuildNativeBundler(); * const wasm = new EsbuildWasmNodeBundler(); * * await native.initialize(); * await wasm.initialize(); * * const nativeResult = await native.bundle(options); * const wasmResult = await wasm.bundle(options); * * // Results should be equivalent (modulo minor formatting differences) * ``` */ export declare class EsbuildWasmNodeBundler implements IBundler { private options; constructor(options?: EsbuildWasmNodeBundlerOptions); /** * Initialize the esbuild WASM module. * Called automatically on first bundle() if not already initialized. * * Uses a global singleton pattern since esbuild-wasm can only be * initialized once per process. */ initialize(): Promise; private doInitialize; /** * Get the initialized esbuild instance. */ private getEsbuild; /** * Dispose of the esbuild WASM service. * This stops the esbuild service and allows the process to exit. * * Note: Since esbuild-wasm uses a global singleton, this affects all * instances. After dispose(), you'll need to create a new bundler. */ dispose(): Promise; bundle(options: BundleOptions): Promise; } /** * Create an esbuild-wasm bundler for Node.js/Bun/Deno. * * This is primarily useful for testing consistency with the browser bundler. * For production use, prefer createEsbuildNativeBundler() which is ~3-5x faster. */ export declare function createEsbuildWasmNodeBundler(options?: EsbuildWasmNodeBundlerOptions): EsbuildWasmNodeBundler; //# sourceMappingURL=wasm-bundler.d.ts.map