CodeGraph/docs
Section 2.6.5

Export Mapping & Specifiers

Mapping exported symbol names to internal symbol IDs across named declarations, aliased specifiers, and default exports.

Source: server/src/parser/extractors/SymbolExtractor.ts

Export Extraction in AST Exit Passes

Export mapping runs during AST exit passes. This ensures that all symbols in the file have already been discovered and assigned IDs before export resolution attempts to bind them.

Export FormAST NodeResolution MechanismExported Name
Declared Named ExportExportNamedDeclaration (declaration)Finds declaration symbol in parsedFile.symbols by location.symbol.name
Variable Declarator ExportExportNamedDeclaration (VariableDeclaration)Iterates declarators, finds symbol by init/declarator location.declarator.name
Specifier ExportExportNamedDeclaration (specifiers)Resolves specifier.local.name via path.scope.getBinding(), maps to symbol.specifier.exported.name
Declared Default ExportExportDefaultDeclaration (declaration)Finds declaration symbol by start location."default"
Identifier Default ExportExportDefaultDeclaration (Identifier)Resolves identifier binding, or falls back to name search for types."default"

Specifier Renaming: `export { foo as bar }`

When a symbol is exported with an alias:

server/src/parser/extractors/SymbolExtractor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// export { internalService as publicApi } for (const specifier of path.node.specifiers) { if (specifier.type !== "ExportSpecifier") continue; // local.name = "internalService" const symbol = this.resolveExportSpecifierToSymbol(parsedFile, path, specifier.local.name); if (!symbol) continue; // exported.name = "publicApi" exportedSymbols.push({ exportedName: specifier.exported.name, // "publicApi" symbolId: symbol.id // Links to internalService symbol ID }); }