collect_imports() — svelte Function Reference
Architecture documentation for the collect_imports() function in create-test.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 07d1108a_41d7_160e_043f_8a5b96c0e542["collect_imports()"] ac45616b_3001_c007_15a3_9896c87b0ad4["create-test.js"] 07d1108a_41d7_160e_043f_8a5b96c0e542 -->|defined in| ac45616b_3001_c007_15a3_9896c87b0ad4 style 07d1108a_41d7_160e_043f_8a5b96c0e542 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
playgrounds/sandbox/scripts/create-test.js lines 82–123
function collect_imports(file_path) {
if (processed_files.has(file_path) || !fs.existsSync(file_path)) {
return;
}
processed_files.add(file_path);
collected_files.add(file_path);
const content = fs.readFileSync(file_path, 'utf8');
// Regex to match import statements
const import_regex = /import\s+(?:[^'"]*\s+from\s+)?['"]([^'"]+)['"]/g;
let match;
while ((match = import_regex.exec(content)) !== null) {
const import_path = match[1];
// Skip node_modules imports
if (!import_path.startsWith('.')) {
continue;
}
// Resolve relative import path
const resolved_path = path.resolve(path.dirname(file_path), import_path);
// Try different extensions if file doesn't exist
const extensions = ['', '.svelte', '.js', '.ts'];
let actual_path = null;
for (const ext of extensions) {
const test_path = resolved_path + ext;
if (fs.existsSync(test_path)) {
actual_path = test_path;
break;
}
}
if (actual_path) {
collect_imports(actual_path);
}
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does collect_imports() do?
collect_imports() is a function in the svelte codebase, defined in playgrounds/sandbox/scripts/create-test.js.
Where is collect_imports() defined?
collect_imports() is defined in playgrounds/sandbox/scripts/create-test.js at line 82.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free