@shopify/cli-kit
Version:
A set of utilities, interfaces, and models that are common across all the platform features
28 lines (27 loc) • 1.28 kB
TypeScript
/**
* Extracts import paths from a source file.
* Supports JavaScript, TypeScript, and Rust files.
*
* @param filePath - Path to the file to analyze.
* @returns Array of absolute paths to imported files.
*/
export declare function extractImportPaths(filePath: string): string[];
/**
* Recursively extracts import paths from a source file and all its dependencies.
* Supports JavaScript, TypeScript, and Rust files.
* Handles circular dependencies by tracking visited files.
*
* @param filePath - Path to the file to analyze.
* @param visited - Set of already visited files to prevent infinite recursion.
* @returns Array of absolute paths to the provided file and all imported files there (including nested imports).
* @throws If an unexpected error occurs while processing files (not including ENOENT file not found errors).
*/
export declare function extractImportPathsRecursively(filePath: string, visited?: Set<string>): string[];
/**
* Extracts import paths from a JavaScript content.
*
* @param content - The content to extract imports from.
* @param filePath - The path to the file to extract imports from.
* @returns Array of absolute paths to imported files.
*/
export declare function extractJSImports(content: string, filePath: string): string[];