Skip to content

Commit

Permalink
fix(schematics): improve utility getNamedImportReferences
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov committed Mar 13, 2024
1 parent 522d94b commit 920ab1a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion projects/cdk/schematics/utils/get-named-import-references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ export function getNamedImportReferences(
);

return arrayFlat(
namedImports.map(specifier => specifier?.findReferencesAsNodes() || []),
namedImports.map(
specifier =>
specifier?.findReferencesAsNodes().filter(
/**
* Otherwise, each `findReferencesAsNodes` will return references across THE WHOLE project.
* It will cause a lot of duplicates in the result and significantly slow down the process.
*/
ref =>
ref.getSourceFile().getFilePath() ===
specifier?.getSourceFile().getFilePath(),
) || [],
),
);
}

0 comments on commit 920ab1a

Please sign in to comment.