@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
52 lines • 2.04 kB
text/typescript
/**
* Converts import statements to const declarations set to null.
* This preserves variable names while removing the actual imports.
* Useful when precomputing data that makes the imports unnecessary.
*
* @param source - The source code to process
* @param importPathsToRewrite - Set of import paths whose import statements should be rewritten
* @param importResult - Import result with position and name data
* @returns The source code with import statements rewritten to const declarations
*/
export declare function rewriteImportsToNull(source: string, importPathsToRewrite: Set<string>, importResult: Record<string, {
positions: Array<{
start: number;
end: number;
}>;
names: Array<{
name: string;
alias?: string;
type: string;
}>;
}>): string;
/**
* Removes entire import statements for the specified import paths.
* This removes the full import line, not just the path.
*
* @param source - The source code to process
* @param importPathsToRemove - Set of import paths whose entire import statements should be removed
* @param importResult - Import result with position data
* @returns The source code with import statements removed
*/
export declare function removeImports(source: string, importPathsToRemove: Set<string>, importResult: Record<string, {
positions: Array<{
start: number;
end: number;
}>;
}>): string;
/**
* Efficiently rewrites import paths using position data.
* This avoids regex parsing and uses precise position information for replacement.
* Works for both JavaScript/TypeScript and CSS imports.
*
* @param source - The source code to process
* @param importPathMapping - Map from original import paths to new import paths
* @param importResult - Import result with position data
* @returns The source code with rewritten import paths
*/
export declare function rewriteImports(source: string, importPathMapping: Map<string, string>, importResult: Record<string, {
positions: Array<{
start: number;
end: number;
}>;
}>): string;