@angular/tsc-wrapped
Advanced tools
Comparing version 4.2.5 to 4.2.6
{ | ||
"name": "@angular/tsc-wrapped", | ||
"version": "4.2.5", | ||
"version": "4.2.6", | ||
"description": "Wraps the tsc CLI, allowing extensions.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/angular/angular/blob/master/tools/@angular/tsc-wrapped", |
@@ -40,2 +40,3 @@ import * as ts from 'typescript'; | ||
private getEntries(exportedSymbols); | ||
private getReExports(exportedSymbols); | ||
private convertSymbol(symbol); | ||
@@ -42,0 +43,0 @@ private convertEntry(moduleName, value); |
@@ -41,3 +41,3 @@ "use strict"; | ||
var origins = Array.from(this.symbolMap.values()) | ||
.filter(function (s) { return s.referenced; }) | ||
.filter(function (s) { return s.referenced && !s.reexport; }) | ||
.reduce(function (p, s) { | ||
@@ -47,4 +47,10 @@ p[s.isPrivate ? s.privateName : s.name] = s.declaration.module; | ||
}, {}); | ||
var exports = this.getReExports(exportedSymbols); | ||
return { | ||
metadata: { __symbolic: 'module', version: schema_1.VERSION, metadata: metadata, origins: origins, importAs: this.importAs }, | ||
metadata: { | ||
__symbolic: 'module', | ||
version: schema_1.VERSION, | ||
exports: exports.length ? exports : undefined, metadata: metadata, origins: origins, | ||
importAs: this.importAs | ||
}, | ||
privates: privates | ||
@@ -104,3 +110,3 @@ }; | ||
// Record all the exports from the module even if we don't use it directly. | ||
this.exportAll(exportFrom); | ||
var exportedSymbols = this.exportAll(exportFrom); | ||
if (exportDeclaration.export) { | ||
@@ -112,2 +118,9 @@ // Re-export all the named exports from a module. | ||
var exportAs = typeof exportItem == 'string' ? exportItem : exportItem.as; | ||
var symbol = this.symbolOf(exportFrom, name_1); | ||
if (exportedSymbols && exportedSymbols.length == 1 && exportedSymbols[0].reexport && | ||
exportedSymbols[0].name == '*') { | ||
// This is a named export from a module we have no metadata about. Record the named | ||
// export as a re-export. | ||
symbol.reexport = true; | ||
} | ||
exportSymbol(this.symbolOf(exportFrom, name_1), exportAs); | ||
@@ -118,5 +131,5 @@ } | ||
// Re-export all the symbols from the module | ||
var exportedSymbols = this.exportAll(exportFrom); | ||
for (var _d = 0, exportedSymbols_1 = exportedSymbols; _d < exportedSymbols_1.length; _d++) { | ||
var exportedSymbol = exportedSymbols_1[_d]; | ||
var exportedSymbols_1 = this.exportAll(exportFrom); | ||
for (var _d = 0, exportedSymbols_2 = exportedSymbols_1; _d < exportedSymbols_2.length; _d++) { | ||
var exportedSymbol = exportedSymbols_2[_d]; | ||
var name_2 = exportedSymbol.name; | ||
@@ -128,2 +141,10 @@ exportSymbol(exportedSymbol, name_2); | ||
} | ||
if (!module) { | ||
// If no metadata is found for this import then it is considered external to the | ||
// library and should be recorded as a re-export in the final metadata if it is | ||
// eventually re-exported. | ||
var symbol = this.symbolOf(moduleName, '*'); | ||
symbol.reexport = true; | ||
result.push(symbol); | ||
} | ||
this.exports.set(moduleName, result); | ||
@@ -150,2 +171,3 @@ return result; | ||
symbol.canonicalSymbol = canonicalSymbol; | ||
symbol.reexport = declaration.reexport; | ||
}; | ||
@@ -174,3 +196,3 @@ MetadataBundler.prototype.getEntries = function (exportedSymbols) { | ||
Array.from(this.symbolMap.values()).forEach(function (symbol) { | ||
if (symbol.referenced) { | ||
if (symbol.referenced && !symbol.reexport) { | ||
var name_3 = symbol.name; | ||
@@ -186,2 +208,32 @@ if (symbol.isPrivate && !symbol.privateName) { | ||
}; | ||
MetadataBundler.prototype.getReExports = function (exportedSymbols) { | ||
var modules = new Map(); | ||
var exportAlls = new Set(); | ||
for (var _i = 0, exportedSymbols_3 = exportedSymbols; _i < exportedSymbols_3.length; _i++) { | ||
var symbol = exportedSymbols_3[_i]; | ||
if (symbol.reexport) { | ||
var declaration = symbol.declaration; | ||
var module_1 = declaration.module; | ||
if (declaration.name == '*') { | ||
// Reexport all the symbols. | ||
exportAlls.add(declaration.module); | ||
} | ||
else { | ||
// Re-export the symbol as the exported name. | ||
var entry = modules.get(module_1); | ||
if (!entry) { | ||
entry = []; | ||
modules.set(module_1, entry); | ||
} | ||
var as = symbol.name; | ||
var name_4 = declaration.name; | ||
entry.push({ name: name_4, as: as }); | ||
} | ||
} | ||
} | ||
return Array.from(exportAlls.values()).map(function (from) { return ({ from: from }); }).concat(Array.from(modules.entries()).map(function (_a) { | ||
var from = _a[0], exports = _a[1]; | ||
return ({ export: exports, from: from }); | ||
})); | ||
}; | ||
MetadataBundler.prototype.convertSymbol = function (symbol) { | ||
@@ -192,5 +244,5 @@ var canonicalSymbol = symbol.canonicalSymbol; | ||
var declaration = canonicalSymbol.declaration; | ||
var module_1 = this.getMetadata(declaration.module); | ||
if (module_1) { | ||
var value = module_1.metadata[declaration.name]; | ||
var module_2 = this.getMetadata(declaration.module); | ||
if (module_2) { | ||
var value = module_2.metadata[declaration.name]; | ||
if (value && !declaration.name.startsWith('___')) { | ||
@@ -228,5 +280,5 @@ canonicalSymbol.value = this.convertEntry(declaration.module, value); | ||
var result = {}; | ||
for (var name_4 in members) { | ||
var value = members[name_4]; | ||
result[name_4] = value.map(function (v) { return _this.convertMember(moduleName, v); }); | ||
for (var name_5 in members) { | ||
var value = members[name_5]; | ||
result[name_5] = value.map(function (v) { return _this.convertMember(moduleName, v); }); | ||
} | ||
@@ -233,0 +285,0 @@ return result; |
@@ -348,3 +348,3 @@ "use strict"; | ||
if (schema_1.isMetadataModuleReferenceExpression(expression_1)) { | ||
// A select into a module refrence and be converted into a reference to the symbol | ||
// A select into a module reference and be converted into a reference to the symbol | ||
// in the module | ||
@@ -351,0 +351,0 @@ return recordEntry({ __symbolic: 'reference', module: expression_1.module, name: member }, node); |
@@ -106,2 +106,20 @@ "use strict"; | ||
}); | ||
it('should be able to bundle a library with re-exported symbols', function () { | ||
var host = new MockStringBundlerHost('/', { | ||
'public-api.ts': "\n export * from './src/core';\n export * from './src/externals';\n ", | ||
'src': { | ||
'core.ts': "\n export class A {}\n export class B extends A {}\n ", | ||
'externals.ts': "\n export {E, F, G} from 'external_one';\n export * from 'external_two';\n " | ||
} | ||
}); | ||
var bundler = new bundler_1.MetadataBundler('/public-api', undefined, host); | ||
var result = bundler.getMetadataBundle(); | ||
expect(result.metadata.exports).toEqual([ | ||
{ from: 'external_two' }, { | ||
export: [{ name: 'E', as: 'E' }, { name: 'F', as: 'F' }, { name: 'G', as: 'G' }], | ||
from: 'external_one' | ||
} | ||
]); | ||
expect(result.metadata.origins['E']).toBeUndefined(); | ||
}); | ||
}); | ||
@@ -108,0 +126,0 @@ var MockStringBundlerHost = (function () { |
@@ -765,3 +765,3 @@ "use strict"; | ||
'`' + | ||
",\n directives: [HeroDetailComponent, common.NgFor],\n providers: [HeroService],\n pipes: [common.LowerCasePipe, common.UpperCasePipe]\n })\n export class AppComponent implements OnInit {\n public title = 'Tour of Heroes';\n public heroes: Hero[];\n public selectedHero: Hero;\n\n constructor(private _heroService: HeroService) { }\n\n onSelect(hero: Hero) { this.selectedHero = hero; }\n\n ngOnInit() {\n this.getHeroes()\n }\n\n getHeroes() {\n this._heroService.getHeroesSlowly().then(heros => this.heroes = heros);\n }\n }", | ||
",\n directives: [HeroDetailComponent, common.NgFor],\n providers: [HeroService],\n pipes: [common.LowerCasePipe, common.UpperCasePipe]\n })\n export class AppComponent implements OnInit {\n public title = 'Tour of Heroes';\n public heroes: Hero[];\n public selectedHero: Hero;\n\n constructor(private _heroService: HeroService) { }\n\n onSelect(hero: Hero) { this.selectedHero = hero; }\n\n ngOnInit() {\n this.getHeroes()\n }\n\n getHeroes() {\n this._heroService.getHeroesSlowly().then(heroes => this.heroes = heroes);\n }\n }", | ||
'hero.ts': "\n export interface Hero {\n id: number;\n name: string;\n }", | ||
@@ -768,0 +768,0 @@ 'empty.ts': "", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
656597
5196