parseImports() — astro Function Reference
Architecture documentation for the parseImports() function in rehype.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 2026ae0c_4235_962c_702f_19eb6663c65a["parseImports()"] 89da4403_ab4a_62fa_64f0_d53bd0b3aee8["rehype.ts"] 2026ae0c_4235_962c_702f_19eb6663c65a -->|defined in| 89da4403_ab4a_62fa_64f0_d53bd0b3aee8 d17ed63a_5ec6_bc29_96d7_b3145cec7d5d["rehypeAnalyzeAstroMetadata()"] d17ed63a_5ec6_bc29_96d7_b3145cec7d5d -->|calls| 2026ae0c_4235_962c_702f_19eb6663c65a style 2026ae0c_4235_962c_702f_19eb6663c65a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/jsx/rehype.ts lines 126–174
function parseImports(children: RootContent[]) {
// Map of import source to its imported specifiers
const imports = new Map<string, Set<ImportSpecifier>>();
for (const child of children) {
if (child.type !== 'mdxjsEsm') continue;
const body = child.data?.estree?.body;
if (!body) continue;
for (const ast of body) {
if (ast.type !== 'ImportDeclaration') continue;
const source = ast.source.value as string;
const specs: ImportSpecifier[] = ast.specifiers.map((spec) => {
switch (spec.type) {
case 'ImportDefaultSpecifier':
return { local: spec.local.name, imported: 'default' };
case 'ImportNamespaceSpecifier':
return { local: spec.local.name, imported: '*' };
case 'ImportSpecifier': {
return {
local: spec.local.name,
imported:
spec.imported.type === 'Identifier'
? spec.imported.name
: String(spec.imported.value),
};
}
default:
throw new Error('Unknown import declaration specifier: ' + spec);
}
});
// Get specifiers set from source or initialize a new one
let specSet = imports.get(source);
if (!specSet) {
specSet = new Set();
imports.set(source, specSet);
}
for (const spec of specs) {
specSet.add(spec);
}
}
}
return imports;
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does parseImports() do?
parseImports() is a function in the astro codebase, defined in packages/astro/src/jsx/rehype.ts.
Where is parseImports() defined?
parseImports() is defined in packages/astro/src/jsx/rehype.ts at line 126.
What calls parseImports()?
parseImports() is called by 1 function(s): rehypeAnalyzeAstroMetadata.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free