@@ -477,6 +477,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
477477 // =>
478478 // var x;... exporter("x", x = 1)
479479 let exportFunctionForFile : string ;
480+ let contextObjectForFile : string ;
480481
481482 let generatedNameSet : Map < string > ;
482483 let nodeToGeneratedName : string [ ] ;
@@ -557,6 +558,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
557558 currentText = undefined ;
558559 currentLineMap = undefined ;
559560 exportFunctionForFile = undefined ;
561+ contextObjectForFile = undefined ;
560562 generatedNameSet = undefined ;
561563 nodeToGeneratedName = undefined ;
562564 computedPropertyNamesToGeneratedNames = undefined ;
@@ -585,6 +587,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
585587 currentText = sourceFile . text ;
586588 currentLineMap = getLineStarts ( sourceFile ) ;
587589 exportFunctionForFile = undefined ;
590+ contextObjectForFile = undefined ;
588591 isEs6Module = sourceFile . symbol && sourceFile . symbol . exports && ! ! sourceFile . symbol . exports [ "___esModule" ] ;
589592 renamedDependencies = sourceFile . renamedDependencies ;
590593 currentFileIdentifiers = sourceFile . identifiers ;
@@ -7058,6 +7061,7 @@ const _super = (function (geti, seti) {
70587061 Debug . assert ( ! exportFunctionForFile ) ;
70597062 // make sure that name of 'exports' function does not conflict with existing identifiers
70607063 exportFunctionForFile = makeUniqueName ( "exports" ) ;
7064+ contextObjectForFile = makeUniqueName ( "context" ) ;
70617065 writeLine ( ) ;
70627066 write ( "System.register(" ) ;
70637067 writeModuleName ( node , emitRelativePathAsModuleName ) ;
@@ -7093,10 +7097,13 @@ const _super = (function (geti, seti) {
70937097
70947098 write ( text ) ;
70957099 }
7096- write ( `], function(${ exportFunctionForFile } ) {` ) ;
7100+ write ( `], function(${ exportFunctionForFile } , ${ contextObjectForFile } ) {` ) ;
70977101 writeLine ( ) ;
70987102 increaseIndent ( ) ;
70997103 const startIndex = emitDirectivePrologues ( node . statements , /*startWithNewLine*/ true , /*ensureUseStrict*/ true ) ;
7104+ writeLine ( ) ;
7105+ write ( `var __moduleName = ${ contextObjectForFile } && ${ contextObjectForFile } .id;` ) ;
7106+ writeLine ( ) ;
71007107 emitEmitHelpers ( node ) ;
71017108 emitCaptureThisForNodeIfNecessary ( node ) ;
71027109 emitSystemModuleBody ( node , dependencyGroups , startIndex ) ;
0 commit comments