fix(compiler): propagate exports when upgrading metadata to v2

This commit is contained in:
Victor Berchet 2016-12-13 10:56:51 -08:00
parent aa3769ba69
commit ee2ac025ef
2 changed files with 8 additions and 3 deletions

View File

@ -189,7 +189,7 @@ export class CompilerHost implements AotCompilerHost {
for (let prop in v1Metadata.metadata) {
v2Metadata.metadata[prop] = v1Metadata.metadata[prop];
}
const sourceText = this.context.readFile(dtsFilePath);
const exports = this.metadataCollector.getMetadata(this.getSourceFile(dtsFilePath));
if (exports) {
for (let prop in exports.metadata) {
@ -197,6 +197,9 @@ export class CompilerHost implements AotCompilerHost {
v2Metadata.metadata[prop] = exports.metadata[prop];
}
}
if (exports.exports) {
v2Metadata.exports = exports.exports;
}
}
metadatas.push(v2Metadata);
}

View File

@ -174,8 +174,9 @@ describe('CompilerHost', () => {
metadata: {
foo: {__symbolic: 'class'},
Bar: {__symbolic: 'class', members: {ngOnInit: [{__symbolic: 'method'}]}},
BarChild: {__symbolic: 'class', extends: {__symbolic: 'reference', name: 'Bar'}}
}
BarChild: {__symbolic: 'class', extends: {__symbolic: 'reference', name: 'Bar'}},
},
exports: [{from: './lib/utils2', export: ['Export']}],
}
]);
});
@ -211,6 +212,7 @@ const FILES: Entry = {
},
'metadata_versions': {
'v1.d.ts': `
export {Export} from './lib/utils2';
export declare class Bar {
ngOnInit() {}
}