build import set of used / duplicate components prior to printing directives so that we can filter duplicates

This fixes a bug where duplicate imports are written: 1 based on the
component link (or extend tag) and the 2nd copied as an existing
directive.  We filter out the existing directive, because that is
invalid (it is an import of the original libray rather than of the
processed component, which is what we want).