Fix #1159 by filtering out unshared top-levels in external modules