ImportAnalyzer Class — drizzle-orm Architecture
Architecture documentation for the ImportAnalyzer class in checker.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 4273b181_859c_5a7c_f3dd_a6a75f179799["ImportAnalyzer"] c2197456_e6cc_1614_c507_f516244187b1["checker.ts"] 4273b181_859c_5a7c_f3dd_a6a75f179799 -->|defined in| c2197456_e6cc_1614_c507_f516244187b1 ce594a0b_155a_f5db_b370_3b3c0464458f["constructor()"] 4273b181_859c_5a7c_f3dd_a6a75f179799 -->|method| ce594a0b_155a_f5db_b370_3b3c0464458f
Relationship Graph
Source Code
drizzle-kit/imports-checker/checker.ts lines 30–237
class ImportAnalyzer {
private localImportRegex = /^(\.?\.?\/|\.\.?$)/;
private importedFileFormatRegex = /^.*\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|json)$/i;
private visited: Set<string> = new Set<string>();
private externals: External[] = [];
private accessChains: Record<string, ChainLink[][]> = {};
constructor(
private basePath: string,
private entry: string,
private listMode: ListMode,
private readonly wantedList: string[],
private localPaths: string[],
private logger?: boolean,
private ignoreTypes?: boolean,
) {}
private isDirectory = (path: string) => {
try {
return fs.lstatSync(path).isDirectory();
} catch (e) {
return false;
}
};
private isFile = (path: string) => {
try {
return fs.lstatSync(path).isFile();
} catch (e) {
return false;
}
};
private localizePath = (path: string) => relative(resolvePath(this.basePath), resolvePath(path));
private isCustomLocal = (importTarget: string) =>
!!this.localPaths.find(
(l) =>
importTarget === l
|| importTarget.startsWith(l.endsWith('/') ? l : `${l}/`),
);
private isLocal = (importTarget: string) =>
this.localImportRegex.test(importTarget)
|| this.isCustomLocal(importTarget);
private isTsFormat = (path: string) => this.importedFileFormatRegex.test(path);
private resolveCustomLocalPath = (
absoluteBase: string,
base: string,
target: string,
): string => {
return joinPath(absoluteBase, target);
};
private resolveTargetFile = (path: string): string => {
if (this.isFile(path)) return path;
const formats = [
'.ts',
'.mts',
'.cts',
'.tsx',
'.js',
'.mjs',
'.cjs',
'.jsx',
];
for (const format of formats) {
const indexPath = joinPath(path, `/index${format}`);
if (this.isFile(indexPath)) return indexPath;
const formatFilePath = `${path}${format}`;
if (this.isFile(formatFilePath)) return formatFilePath;
}
return path;
};
Domain
Defined In
Source
Frequently Asked Questions
What is the ImportAnalyzer class?
ImportAnalyzer is a class in the drizzle-orm codebase, defined in drizzle-kit/imports-checker/checker.ts.
Where is ImportAnalyzer defined?
ImportAnalyzer is defined in drizzle-kit/imports-checker/checker.ts at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free