From ee2ac025ef0343f2701577087944d3a748b325f7 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 13 Dec 2016 10:56:51 -0800 Subject: [PATCH] fix(compiler): propagate exports when upgrading metadata to v2 --- modules/@angular/compiler-cli/src/compiler_host.ts | 5 ++++- modules/@angular/compiler-cli/test/aot_host_spec.ts | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/@angular/compiler-cli/src/compiler_host.ts b/modules/@angular/compiler-cli/src/compiler_host.ts index 3cca44187d..3360d1d28f 100644 --- a/modules/@angular/compiler-cli/src/compiler_host.ts +++ b/modules/@angular/compiler-cli/src/compiler_host.ts @@ -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); } diff --git a/modules/@angular/compiler-cli/test/aot_host_spec.ts b/modules/@angular/compiler-cli/test/aot_host_spec.ts index cef1f3d0de..65e2e3eee6 100644 --- a/modules/@angular/compiler-cli/test/aot_host_spec.ts +++ b/modules/@angular/compiler-cli/test/aot_host_spec.ts @@ -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() {} }