fix(tsc-wrapped): deduplicate metadata only when the module is the same (#19249)

Fixes #19219
PR Close #19249
This commit is contained in:
Olivier Combe
2017-09-18 15:43:02 +02:00
committed by Igor Minar
parent 2373186239
commit b6b18c1d7f
4 changed files with 26 additions and 12 deletions

View File

@ -265,24 +265,25 @@ export class MetadataBundler {
Array.from(this.symbolMap.values()).forEach(symbol => {
if (symbol.referenced && !symbol.reexport) {
let name = symbol.name;
const declaredName = symbol.declaration !.name;
const identifier = `${symbol.declaration!.module}:${symbol.declaration !.name}`;
if (symbol.isPrivate && !symbol.privateName) {
name = newPrivateName();
symbol.privateName = name;
}
if (symbolsMap.has(declaredName)) {
const names = symbolsMap.get(declaredName);
if (symbolsMap.has(identifier)) {
const names = symbolsMap.get(identifier);
names !.push(name);
} else {
symbolsMap.set(declaredName, [name]);
symbolsMap.set(identifier, [name]);
}
result[name] = symbol.value !;
}
});
// check for duplicated entries
symbolsMap.forEach((names: string[], declaredName: string) => {
symbolsMap.forEach((names: string[], identifier: string) => {
if (names.length > 1) {
const [module, declaredName] = identifier.split(':');
// prefer the export that uses the declared name (if any)
let reference = names.indexOf(declaredName);
if (reference === -1) {