@@ -3090,7 +3090,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
30903090 }
30913091 }
30923092
3093- function emitExportMemberAssignmentsInNonSystemModule ( name : Identifier ) {
3093+ function emitExportMemberAssignments ( name : Identifier ) {
30943094 if ( compilerOptions . module === ModuleKind . System ) {
30953095 return ;
30963096 }
@@ -3412,7 +3412,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
34123412 }
34133413 let name = node . name ;
34143414 if ( name . kind === SyntaxKind . Identifier ) {
3415- emitExportMemberAssignmentsInNonSystemModule ( < Identifier > name ) ;
3415+ emitExportMemberAssignments ( < Identifier > name ) ;
34163416 }
34173417 else if ( isBindingPattern ( name ) ) {
34183418 forEach ( ( < BindingPattern > name ) . elements , emitExportVariableAssignments ) ;
@@ -3667,7 +3667,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
36673667
36683668 emitSignatureAndBody ( node ) ;
36693669 if ( languageVersion < ScriptTarget . ES6 && node . kind === SyntaxKind . FunctionDeclaration && node . parent === currentSourceFile && node . name ) {
3670- emitExportMemberAssignmentsInNonSystemModule ( ( < FunctionDeclaration > node ) . name ) ;
3670+ emitExportMemberAssignments ( ( < FunctionDeclaration > node ) . name ) ;
36713671 }
36723672 if ( node . kind !== SyntaxKind . MethodDeclaration && node . kind !== SyntaxKind . MethodSignature ) {
36733673 emitTrailingComments ( node ) ;
@@ -4590,7 +4590,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
45904590 }
45914591
45924592 if ( languageVersion < ScriptTarget . ES6 && node . parent === currentSourceFile && node . name ) {
4593- emitExportMemberAssignmentsInNonSystemModule ( node . name ) ;
4593+ emitExportMemberAssignments ( node . name ) ;
45944594 }
45954595 }
45964596
@@ -5179,7 +5179,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
51795179 emitDeclarationName ( node ) ;
51805180 write ( ");" ) ;
51815181 }
5182- emitExportMemberAssignmentsInNonSystemModule ( node . name ) ;
5182+ emitExportMemberAssignments ( node . name ) ;
51835183 }
51845184 }
51855185
@@ -5300,7 +5300,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53005300 emitDeclarationName ( node ) ;
53015301 write ( ");" ) ;
53025302 }
5303- emitExportMemberAssignmentsInNonSystemModule ( < Identifier > node . name ) ;
5303+ emitExportMemberAssignments ( < Identifier > node . name ) ;
53045304 }
53055305 }
53065306
@@ -5333,7 +5333,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53335333
53345334 function emitExportImportAssignments ( node : Node ) {
53355335 if ( isAliasSymbolDeclaration ( node ) && resolver . isValueAliasDeclaration ( node ) ) {
5336- emitExportMemberAssignmentsInNonSystemModule ( < Identifier > ( < Declaration > node ) . name ) ;
5336+ emitExportMemberAssignments ( < Identifier > ( < Declaration > node ) . name ) ;
53375337 }
53385338 forEachChild ( node , emitExportImportAssignments ) ;
53395339 }
@@ -6155,23 +6155,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
61556155 if ( ( < ExportDeclaration > entry ) . exportClause ) {
61566156 // export {a, b as c} from 'foo'
61576157 // emit as:
6158- // var reexports = {}
6159- // reexports['a'] = _foo["a"];
6160- // reexports['c'] = _foo["b"];
6161- // exports_(reexports);
6162- let reexportsVariableName = makeUniqueName ( "reexports" ) ;
6158+ // exports_({
6159+ // "a": _["a"],
6160+ // "c": _["b"]
6161+ // });
61636162 writeLine ( ) ;
6164- write ( `var ${ reexportsVariableName } = {}; ` ) ;
6163+ write ( `${ exportFunctionForFile } ({ ` ) ;
61656164 writeLine ( ) ;
6166- for ( let e of ( < ExportDeclaration > entry ) . exportClause . elements ) {
6167- write ( `${ reexportsVariableName } ["` ) ;
6165+ increaseIndent ( ) ;
6166+ for ( let i = 0 , len = ( < ExportDeclaration > entry ) . exportClause . elements . length ; i < len ; ++ i ) {
6167+ if ( i !== 0 ) {
6168+ write ( "," ) ;
6169+ writeLine ( ) ;
6170+ }
6171+
6172+ let e = ( < ExportDeclaration > entry ) . exportClause . elements [ i ] ;
6173+ write ( `"` ) ;
61686174 emitNodeWithoutSourceMap ( e . name ) ;
6169- write ( `"] = ${ parameterName } ["` ) ;
6175+ write ( `": ${ parameterName } ["` ) ;
61706176 emitNodeWithoutSourceMap ( e . propertyName || e . name ) ;
6171- write ( `"];` ) ;
6172- writeLine ( ) ;
6177+ write ( `"]` ) ;
61736178 }
6174- write ( `${ exportFunctionForFile } (${ reexportsVariableName } );` ) ;
6179+ decreaseIndent ( ) ;
6180+ writeLine ( ) ;
6181+ write ( "});" )
61756182 }
61766183 else {
61776184 writeLine ( ) ;
@@ -6206,15 +6213,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
62066213 // - import declarations are not emitted since they are already handled in setters
62076214 // - export declarations with module specifiers are not emitted since they were already written in setters
62086215 // - export declarations without module specifiers are emitted preserving the order
6209- case SyntaxKind . FunctionDeclaration :
6210- case SyntaxKind . ExportDeclaration :
6216+ case SyntaxKind . FunctionDeclaration :
62116217 case SyntaxKind . ImportDeclaration :
6212- if ( statement . kind === SyntaxKind . ExportDeclaration ) {
6213- if ( ! ( < ExportDeclaration > statement ) . moduleSpecifier ) {
6214- for ( let element of ( < ExportDeclaration > statement ) . exportClause . elements ) {
6215- // write call to exporter function for every export specifier in exports list
6216- emitExportSpecifierInSystemModule ( element ) ;
6217- }
6218+ continue ;
6219+ case SyntaxKind . ExportDeclaration :
6220+ if ( ! ( < ExportDeclaration > statement ) . moduleSpecifier ) {
6221+ for ( let element of ( < ExportDeclaration > statement ) . exportClause . elements ) {
6222+ // write call to exporter function for every export specifier in exports list
6223+ emitExportSpecifierInSystemModule ( element ) ;
62186224 }
62196225 }
62206226 continue ;
0 commit comments