UNPKG

@pulzar/core

Version:

Next-generation Node.js framework for ultra-fast web applications with zero-reflection DI, GraphQL, WebSockets, events, and edge runtime support

124 lines 3.18 kB
import * as esbuild from "esbuild"; import { EdgePlatform } from "./types"; export interface EdgeBundlerOptions { platform: EdgePlatform; entry: string; outDir: string; outFile?: string; minify?: boolean; sourcemap?: boolean; external?: string[]; define?: Record<string, string>; target?: string; format?: "esm" | "cjs"; splitting?: boolean; metafile?: boolean; bundle?: boolean; keepNames?: boolean; legalComments?: "none" | "inline" | "eof" | "linked" | "external"; treeShaking?: boolean; watch?: boolean; polyfills?: boolean; frameworkName?: string; onBuildStart?: () => void; onBuildEnd?: (result: esbuild.BuildResult, duration: number) => void; onBuildError?: (error: Error) => void; } export interface BundleResult { success: boolean; outputFiles: string[]; metafile?: esbuild.Metafile; warnings: esbuild.Message[]; errors: esbuild.Message[]; duration: number; size: number; } export declare class EdgeBundler { private options; private esbuildContext?; private watcher?; private isWatching; constructor(options: EdgeBundlerOptions); /** * Bundle the application for edge deployment */ bundle(): Promise<BundleResult>; /** * Start watching for changes and rebuild automatically */ startWatch(): Promise<void>; /** * Stop watching */ stopWatch(): Promise<void>; /** * Analyze bundle contents */ analyze(): Promise<{ metafile: esbuild.Metafile; analysis: string; dependencies: Array<{ name: string; size: number; percentage: number; }>; }>; /** * Get platform-specific build target */ private getPlatformTarget; /** * Create esbuild configuration */ private createBuildOptions; /** * Get platform-specific externals */ private getPlatformExternals; /** * Create polyfill plugin */ private createPolyfillPlugin; /** * Create platform-specific plugin */ private createPlatformPlugin; /** * Create bundle size analyzer plugin */ private createSizeAnalyzerPlugin; /** * Setup file watcher for additional files */ private setupFileWatcher; /** * Process build result */ private processBuildResult; /** * Extract dependencies from metafile */ private extractDependencies; /** * Get total bundle size from metafile */ private getTotalBundleSize; /** * Get build statistics */ getStats(): { platform: EdgePlatform; isWatching: boolean; options: EdgeBundlerOptions; }; } /** * Create and configure an edge bundler */ export declare function createEdgeBundler(options: EdgeBundlerOptions): EdgeBundler; /** * Quick bundle function for simple use cases */ export declare function bundleForEdge(entry: string, platform: EdgePlatform, outDir: string, options?: Partial<EdgeBundlerOptions>): Promise<BundleResult>; export default EdgeBundler; //# sourceMappingURL=bundler.d.ts.map