@@ -477,6 +477,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
477
477
// =>
478
478
// var x;... exporter("x", x = 1)
479
479
let exportFunctionForFile : string ;
480
+ let contextObjectForFile : string ;
480
481
481
482
let generatedNameSet : Map < string > ;
482
483
let nodeToGeneratedName : string [ ] ;
@@ -557,6 +558,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
557
558
currentText = undefined ;
558
559
currentLineMap = undefined ;
559
560
exportFunctionForFile = undefined ;
561
+ contextObjectForFile = undefined ;
560
562
generatedNameSet = undefined ;
561
563
nodeToGeneratedName = undefined ;
562
564
computedPropertyNamesToGeneratedNames = undefined ;
@@ -585,6 +587,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
585
587
currentText = sourceFile . text ;
586
588
currentLineMap = getLineStarts ( sourceFile ) ;
587
589
exportFunctionForFile = undefined ;
590
+ contextObjectForFile = undefined ;
588
591
isEs6Module = sourceFile . symbol && sourceFile . symbol . exports && ! ! sourceFile . symbol . exports [ "___esModule" ] ;
589
592
renamedDependencies = sourceFile . renamedDependencies ;
590
593
currentFileIdentifiers = sourceFile . identifiers ;
@@ -7058,6 +7061,7 @@ const _super = (function (geti, seti) {
7058
7061
Debug . assert ( ! exportFunctionForFile ) ;
7059
7062
// make sure that name of 'exports' function does not conflict with existing identifiers
7060
7063
exportFunctionForFile = makeUniqueName ( "exports" ) ;
7064
+ contextObjectForFile = makeUniqueName ( "context" ) ;
7061
7065
writeLine ( ) ;
7062
7066
write ( "System.register(" ) ;
7063
7067
writeModuleName ( node , emitRelativePathAsModuleName ) ;
@@ -7093,10 +7097,13 @@ const _super = (function (geti, seti) {
7093
7097
7094
7098
write ( text ) ;
7095
7099
}
7096
- write ( `], function(${ exportFunctionForFile } ) {` ) ;
7100
+ write ( `], function(${ exportFunctionForFile } , ${ contextObjectForFile } ) {` ) ;
7097
7101
writeLine ( ) ;
7098
7102
increaseIndent ( ) ;
7099
7103
const startIndex = emitDirectivePrologues ( node . statements , /*startWithNewLine*/ true , /*ensureUseStrict*/ true ) ;
7104
+ writeLine ( ) ;
7105
+ write ( `var __moduleName = ${ contextObjectForFile } && ${ contextObjectForFile } .id;` ) ;
7106
+ writeLine ( ) ;
7100
7107
emitEmitHelpers ( node ) ;
7101
7108
emitCaptureThisForNodeIfNecessary ( node ) ;
7102
7109
emitSystemModuleBody ( node , dependencyGroups , startIndex ) ;
0 commit comments