UNPKG

@devlander/collect-exports-for-bundle

Version:

Generate comprehensive export files for TypeScript/JavaScript projects with Rollup compatibility

107 lines (106 loc) 3.07 kB
import { ModuleExportOptions } from '../types/module-exporter.types'; export interface ExportStrategy { name: string; description: string; generateExports(files: string[], config: ModuleExportOptions): ExportOutput; } export interface ExportOutput { imports: string[]; exports: string[]; defaultExport?: string; bundleObject?: string; header: string[]; } export interface ExportFile { path: string; name: string; relativePath: string; hasDefaultExport: boolean; hasNamedExports: boolean; exports: string[]; } export interface RollupCompatibilityConfig { rollupCompatible: boolean; includeExtensions: boolean; bundlerTarget: 'rollup' | 'webpack' | 'vite' | 'parcel' | 'node'; pathResolution: { mode: 'bundler' | 'node' | 'auto'; extensions: string[]; resolveStrategy: 'explicit' | 'implicit' | 'smart'; }; typescript: { generateBarrelExports: boolean; includeTypeOnlyExports: boolean; preserveJSDocComments: boolean; exportStrategy: 'minimal' | 'comprehensive' | 'selective'; }; validation: { validatePaths: boolean; checkCircularDependencies: boolean; validateTypeScript: boolean; failOnErrors: boolean; }; performance: { enableCaching: boolean; cacheDirectory: string; incrementalGeneration: boolean; parallelProcessing: boolean; }; } /** * Clean export generator that eliminates conflicts between different export modes * and provides comprehensive Rollup compatibility */ export declare class ExportGenerator { private config; private rollupConfig; constructor(config: ModuleExportOptions); /** * Initialize Rollup compatibility configuration with defaults */ private initializeRollupConfig; /** * Main entry point - generates exports based on configuration */ generateExports(files: string[]): ExportOutput; /** * Apply Rollup compatibility transformations to export paths */ private applyRollupCompatibility; /** * Add file extensions to export paths for Rollup compatibility */ private addFileExtensions; /** * Validate export paths exist */ private validateExportPaths; /** * Parse files to understand their export structure */ private parseFiles; /** * Select the appropriate export strategy based on configuration */ private selectExportStrategy; /** * Generate header information for the export file */ private generateHeader; /** * Extract file name without extension */ private extractFileName; /** * Make path relative to root directory */ private makeRelativePath; } /** * Convenience function to generate exports */ export declare function generateExports(files: string[], config: ModuleExportOptions): ExportOutput; /** * Format export output into a string */ export declare function formatExportOutput(output: ExportOutput): string;