@@ -45,7 +45,6 @@ namespace ts {
45
45
let currentSourceFile : SourceFile ; // The current file.
46
46
let currentModuleInfo : ExternalModuleInfo ; // The ExternalModuleInfo for the current file.
47
47
let noSubstitution : boolean [ ] ; // Set of nodes for which substitution rules should be ignored.
48
- let shouldAppendEsModuleMarker : boolean ; // A boolean indicating whether "__esModule" should be emitted
49
48
50
49
return transformSourceFile ;
51
50
@@ -63,7 +62,6 @@ namespace ts {
63
62
64
63
currentSourceFile = node ;
65
64
currentModuleInfo = collectExternalModuleInfo ( node , resolver , compilerOptions ) ;
66
- shouldAppendEsModuleMarker = false ;
67
65
moduleInfoMap [ getOriginalNodeId ( node ) ] = currentModuleInfo ;
68
66
69
67
// Perform the transformation.
@@ -90,7 +88,7 @@ namespace ts {
90
88
addRange ( statements , endLexicalEnvironment ( ) ) ;
91
89
addExportEqualsIfNeeded ( statements , /*emitAsReturn*/ false ) ;
92
90
93
- if ( shouldAppendEsModuleMarker ) {
91
+ if ( ! currentModuleInfo . exportEquals ) {
94
92
append ( statements , createUnderscoreUnderscoreESModule ( ) ) ;
95
93
}
96
94
@@ -387,7 +385,7 @@ namespace ts {
387
385
// Append the 'export =' statement if provided.
388
386
addExportEqualsIfNeeded ( statements , /*emitAsReturn*/ true ) ;
389
387
390
- if ( shouldAppendEsModuleMarker ) {
388
+ if ( ! currentModuleInfo . exportEquals ) {
391
389
append ( statements , createUnderscoreUnderscoreESModule ( ) ) ;
392
390
}
393
391
@@ -674,7 +672,6 @@ namespace ts {
674
672
}
675
673
676
674
const generatedName = getGeneratedNameForNode ( node ) ;
677
- shouldAppendEsModuleMarker = true ;
678
675
679
676
if ( node . exportClause ) {
680
677
const statements : Statement [ ] = [ ] ;
@@ -850,13 +847,6 @@ namespace ts {
850
847
let variables : VariableDeclaration [ ] ;
851
848
let expressions : Expression [ ] ;
852
849
853
- const parseTreeNode = getParseTreeNode ( node ) ;
854
- if ( parseTreeNode && ! shouldAppendEsModuleMarker ) {
855
- // class declaration get down-level transformed to be variable statement
856
- shouldAppendEsModuleMarker = ( parseTreeNode . kind === SyntaxKind . VariableStatement || parseTreeNode . kind === SyntaxKind . ClassDeclaration || parseTreeNode . kind === SyntaxKind . ImportEqualsDeclaration )
857
- && hasModifier ( parseTreeNode , ModifierFlags . Export ) ;
858
- }
859
-
860
850
if ( hasModifier ( node , ModifierFlags . Export ) ) {
861
851
let modifiers : NodeArray < Modifier > ;
862
852
@@ -1146,7 +1136,6 @@ namespace ts {
1146
1136
* @param allowComments Whether to allow comments on the export.
1147
1137
*/
1148
1138
function appendExportStatement ( statements : Statement [ ] | undefined , exportName : Identifier , expression : Expression , location ?: TextRange , allowComments ?: boolean ) : Statement [ ] | undefined {
1149
- shouldAppendEsModuleMarker = true ;
1150
1139
statements = append ( statements , createExportStatement ( exportName , expression , location , allowComments ) ) ;
1151
1140
return statements ;
1152
1141
}
0 commit comments