/** * Interface for folder mapping between source and destination */ export interface IFolderMapping { sourceFolder: string; destFolder: string; } /** * TsPathRewriter handles rewriting import paths in compiled JavaScript files. * * When TypeScript compiles files that import from sibling directories like: * import { helper } from '../ts_shared/helper.js'; * * This class rewrites them to point to the compiled output directories: * import { helper } from '../dist_ts_shared/helper.js'; * * This is necessary because the unpack feature flattens nested output structures, * changing the relative paths between modules. */ export declare class TsPathRewriter { private mappings; constructor(mappings: IFolderMapping[]); /** * Create a TsPathRewriter from glob patterns used in compilation * * @param globPatterns - Map of source patterns to destination directories * e.g., { './ts_core/**\/*.ts': './dist_ts_core', './ts_shared/**\/*.ts': './dist_ts_shared' } * @returns TsPathRewriter instance with extracted folder mappings */ static fromGlobPatterns(globPatterns: Record): TsPathRewriter; /** * Create a TsPathRewriter by auto-detecting all ts_* folders in the project directory. * This ensures that cross-module imports are rewritten even when compiling a single module. * * For example, if the project has ts/, ts_shared/, ts_web/ folders: * - ts → dist_ts * - ts_shared → dist_ts_shared * - ts_web → dist_ts_web * * @param cwd - The project root directory * @returns TsPathRewriter instance with all detected folder mappings */ static fromProjectDirectory(cwd: string): Promise; /** * Get the current folder mappings */ getMappings(): IFolderMapping[]; /** * Rewrite import paths in a single file * * @param filePath - Absolute path to the file to rewrite * @returns true if file was modified, false otherwise */ rewriteFile(filePath: string): Promise; /** * Rewrite import paths in all .js and .d.ts files in a directory (recursively) * * @param dirPath - Absolute path to the directory * @returns Number of files modified */ rewriteDirectory(dirPath: string): Promise; /** * Rewrite import paths in content string * * This method only modifies actual import/export/require statements, * not arbitrary strings or comments that might contain similar patterns. * * @param content - File content to process * @returns Rewritten content */ rewriteContent(content: string): string; /** * Escape special regex characters in a string */ private escapeRegex; } /** * Convenience function to rewrite import paths in output directories * * @param globPatterns - Map of source patterns to destination directories * @param outputDirs - List of output directories to process * @returns Total number of files modified */ export declare function rewriteImportPaths(globPatterns: Record, outputDirs: string[]): Promise;