Skip to content

Commit 4568a8d

Browse files
AlpAlp
authored andcommitted
perf: use targeted AST lookups instead of getExportedDeclarations
Replace sourceFile.getExportedDeclarations() (which resolves all exports and forces type checker work) with targeted lookups: - getExportAssignment() for default exports - getVariableDeclaration(name) for named exports ~10% improvement in lazy mode (9.06s -> 8.12s on real monorepo).
1 parent aa835a4 commit 4568a8d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/cli/config.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,18 @@ export function getZeroSchemaDefsFromConfig({
8787
);
8888
}
8989

90-
const exportDeclarations = sourceFile.getExportedDeclarations();
91-
92-
for (const [name, declarations] of exportDeclarations.entries()) {
93-
for (const declaration of declarations) {
94-
if (exportName === name) {
95-
return [name, declaration] as const;
96-
}
90+
// Targeted lookup avoids getExportedDeclarations() which forces full type resolution
91+
if (exportName === 'default') {
92+
const exportAssignment = sourceFile.getExportAssignment(
93+
d => !d.isExportEquals(),
94+
);
95+
if (exportAssignment) {
96+
return [exportName, exportAssignment] as const;
97+
}
98+
} else {
99+
const variableDeclaration = sourceFile.getVariableDeclaration(exportName);
100+
if (variableDeclaration) {
101+
return [exportName, variableDeclaration] as const;
97102
}
98103
}
99104

0 commit comments

Comments
 (0)