@@ -45,7 +45,7 @@ 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 shouldAppendUnderscoreUnderscoreEsModule : boolean ; // A boolean indicating whether "__esModule" should be emitted
48
+ let shouldAppendEsModuleMarker : boolean ; // A boolean indicating whether "__esModule" should be emitted
49
49
50
50
return transformSourceFile ;
51
51
@@ -63,7 +63,7 @@ namespace ts {
63
63
64
64
currentSourceFile = node ;
65
65
currentModuleInfo = collectExternalModuleInfo ( node , resolver , compilerOptions ) ;
66
- shouldAppendUnderscoreUnderscoreEsModule = false ;
66
+ shouldAppendEsModuleMarker = false ;
67
67
moduleInfoMap [ getOriginalNodeId ( node ) ] = currentModuleInfo ;
68
68
69
69
// Perform the transformation.
@@ -90,7 +90,7 @@ namespace ts {
90
90
addRange ( statements , endLexicalEnvironment ( ) ) ;
91
91
addExportEqualsIfNeeded ( statements , /*emitAsReturn*/ false ) ;
92
92
93
- if ( shouldAppendUnderscoreUnderscoreEsModule ) {
93
+ if ( shouldAppendEsModuleMarker ) {
94
94
append ( statements , createUnderscoreUnderscoreESModule ( ) ) ;
95
95
}
96
96
@@ -383,7 +383,7 @@ namespace ts {
383
383
// Append the 'export =' statement if provided.
384
384
addExportEqualsIfNeeded ( statements , /*emitAsReturn*/ true ) ;
385
385
386
- if ( shouldAppendUnderscoreUnderscoreEsModule ) {
386
+ if ( shouldAppendEsModuleMarker ) {
387
387
append ( statements , createUnderscoreUnderscoreESModule ( ) ) ;
388
388
}
389
389
@@ -666,7 +666,7 @@ namespace ts {
666
666
}
667
667
668
668
const generatedName = getGeneratedNameForNode ( node ) ;
669
- shouldAppendUnderscoreUnderscoreEsModule = true ;
669
+ shouldAppendEsModuleMarker = true ;
670
670
671
671
if ( node . exportClause ) {
672
672
const statements : Statement [ ] = [ ] ;
@@ -833,9 +833,10 @@ namespace ts {
833
833
let expressions : Expression [ ] ;
834
834
835
835
const parseTreeNode = getParseTreeNode ( node ) ;
836
- if ( ! shouldAppendUnderscoreUnderscoreEsModule ) {
836
+ if ( parseTreeNode && ! shouldAppendEsModuleMarker ) {
837
837
// class declaration get down-level transformed to be variable statement
838
- shouldAppendUnderscoreUnderscoreEsModule = ( parseTreeNode . kind === SyntaxKind . VariableStatement || parseTreeNode . kind === SyntaxKind . ClassDeclaration ) && hasModifier ( parseTreeNode , ModifierFlags . Export ) ;
838
+ shouldAppendEsModuleMarker = ( parseTreeNode . kind === SyntaxKind . VariableStatement || parseTreeNode . kind === SyntaxKind . ClassDeclaration || parseTreeNode . kind === SyntaxKind . ImportEqualsDeclaration )
839
+ && hasModifier ( parseTreeNode , ModifierFlags . Export ) ;
839
840
}
840
841
841
842
if ( hasModifier ( node , ModifierFlags . Export ) ) {
@@ -1125,7 +1126,7 @@ namespace ts {
1125
1126
* @param allowComments Whether to allow comments on the export.
1126
1127
*/
1127
1128
function appendExportStatement ( statements : Statement [ ] | undefined , exportName : Identifier , expression : Expression , location ?: TextRange , allowComments ?: boolean ) : Statement [ ] | undefined {
1128
- shouldAppendUnderscoreUnderscoreEsModule = true ;
1129
+ shouldAppendEsModuleMarker = true ;
1129
1130
statements = append ( statements , createExportStatement ( exportName , expression , location , allowComments ) ) ;
1130
1131
return statements ;
1131
1132
}
0 commit comments