fix(compiler): allow to use lowering with export *
.
Previously, we generated incorrect code when a file had lowerings and also exported another file via `export *` that also had lowerings in it.
This commit is contained in:

committed by
Victor Berchet

parent
3799f43c71
commit
e31a76ce24
@ -292,34 +292,6 @@ export class StaticSymbolResolver {
|
||||
this.resolvedFilePaths.add(filePath);
|
||||
const resolvedSymbols: ResolvedStaticSymbol[] = [];
|
||||
const metadata = this.getModuleMetadata(filePath);
|
||||
if (metadata['metadata']) {
|
||||
// handle direct declarations of the symbol
|
||||
const topLevelSymbolNames =
|
||||
new Set<string>(Object.keys(metadata['metadata']).map(unescapeIdentifier));
|
||||
const origins: {[index: string]: string} = metadata['origins'] || {};
|
||||
Object.keys(metadata['metadata']).forEach((metadataKey) => {
|
||||
const symbolMeta = metadata['metadata'][metadataKey];
|
||||
const name = unescapeIdentifier(metadataKey);
|
||||
|
||||
const symbol = this.getStaticSymbol(filePath, name);
|
||||
|
||||
const origin = origins.hasOwnProperty(metadataKey) && origins[metadataKey];
|
||||
if (origin) {
|
||||
// If the symbol is from a bundled index, use the declaration location of the
|
||||
// symbol so relative references (such as './my.html') will be calculated
|
||||
// correctly.
|
||||
const originFilePath = this.resolveModule(origin, filePath);
|
||||
if (!originFilePath) {
|
||||
this.reportError(
|
||||
new Error(`Couldn't resolve original symbol for ${origin} from ${filePath}`));
|
||||
} else {
|
||||
this.symbolResourcePaths.set(symbol, originFilePath);
|
||||
}
|
||||
}
|
||||
resolvedSymbols.push(
|
||||
this.createResolvedSymbol(symbol, filePath, topLevelSymbolNames, symbolMeta));
|
||||
});
|
||||
}
|
||||
|
||||
// handle the symbols in one of the re-export location
|
||||
if (metadata['exports']) {
|
||||
@ -358,6 +330,38 @@ export class StaticSymbolResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle the actual metadata. Has to be after the exports
|
||||
// as there migth be collisions in the names, and we want the symbols
|
||||
// of the current module to win ofter reexports.
|
||||
if (metadata['metadata']) {
|
||||
// handle direct declarations of the symbol
|
||||
const topLevelSymbolNames =
|
||||
new Set<string>(Object.keys(metadata['metadata']).map(unescapeIdentifier));
|
||||
const origins: {[index: string]: string} = metadata['origins'] || {};
|
||||
Object.keys(metadata['metadata']).forEach((metadataKey) => {
|
||||
const symbolMeta = metadata['metadata'][metadataKey];
|
||||
const name = unescapeIdentifier(metadataKey);
|
||||
|
||||
const symbol = this.getStaticSymbol(filePath, name);
|
||||
|
||||
const origin = origins.hasOwnProperty(metadataKey) && origins[metadataKey];
|
||||
if (origin) {
|
||||
// If the symbol is from a bundled index, use the declaration location of the
|
||||
// symbol so relative references (such as './my.html') will be calculated
|
||||
// correctly.
|
||||
const originFilePath = this.resolveModule(origin, filePath);
|
||||
if (!originFilePath) {
|
||||
this.reportError(
|
||||
new Error(`Couldn't resolve original symbol for ${origin} from ${filePath}`));
|
||||
} else {
|
||||
this.symbolResourcePaths.set(symbol, originFilePath);
|
||||
}
|
||||
}
|
||||
resolvedSymbols.push(
|
||||
this.createResolvedSymbol(symbol, filePath, topLevelSymbolNames, symbolMeta));
|
||||
});
|
||||
}
|
||||
resolvedSymbols.forEach(
|
||||
(resolvedSymbol) => this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol));
|
||||
this.symbolFromFile.set(filePath, resolvedSymbols.map(resolvedSymbol => resolvedSymbol.symbol));
|
||||
|
Reference in New Issue
Block a user