@@ -320,7 +320,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
320320
321321 const awaiterHelper = `
322322var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
323- return new P (function (resolve, reject) {
323+ return new (P || (P = Promise)) (function (resolve, reject) {
324324 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
325325 function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
326326 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
@@ -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 ;
@@ -4561,11 +4564,11 @@ const _super = (function (geti, seti) {
45614564 write ( ", void 0, " ) ;
45624565 }
45634566
4564- if ( promiseConstructor ) {
4565- emitEntityNameAsExpression ( promiseConstructor , /*useFallback*/ false ) ;
4567+ if ( languageVersion >= ScriptTarget . ES6 || ! promiseConstructor ) {
4568+ write ( "void 0" ) ;
45664569 }
45674570 else {
4568- write ( "Promise" ) ;
4571+ emitEntityNameAsExpression ( promiseConstructor , /*useFallback*/ false ) ;
45694572 }
45704573
45714574 // Emit the call to __awaiter.
@@ -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 ) ;
@@ -7068,14 +7072,22 @@ const _super = (function (geti, seti) {
70687072
70697073 for ( let i = 0 ; i < externalImports . length ; i ++ ) {
70707074 const text = getExternalModuleNameText ( externalImports [ i ] , emitRelativePathAsModuleName ) ;
7071- if ( hasProperty ( groupIndices , text ) ) {
7075+ if ( text === undefined ) {
7076+ continue ;
7077+ }
7078+
7079+ // text should be quoted string
7080+ // for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same
7081+ const key = text . substr ( 1 , text . length - 2 ) ;
7082+
7083+ if ( hasProperty ( groupIndices , key ) ) {
70727084 // deduplicate/group entries in dependency list by the dependency name
7073- const groupIndex = groupIndices [ text ] ;
7085+ const groupIndex = groupIndices [ key ] ;
70747086 dependencyGroups [ groupIndex ] . push ( externalImports [ i ] ) ;
70757087 continue ;
70767088 }
70777089 else {
7078- groupIndices [ text ] = dependencyGroups . length ;
7090+ groupIndices [ key ] = dependencyGroups . length ;
70797091 dependencyGroups . push ( [ externalImports [ i ] ] ) ;
70807092 }
70817093
@@ -7085,10 +7097,13 @@ const _super = (function (geti, seti) {
70857097
70867098 write ( text ) ;
70877099 }
7088- write ( `], function(${ exportFunctionForFile } ) {` ) ;
7100+ write ( `], function(${ exportFunctionForFile } , ${ contextObjectForFile } ) {` ) ;
70897101 writeLine ( ) ;
70907102 increaseIndent ( ) ;
70917103 const startIndex = emitDirectivePrologues ( node . statements , /*startWithNewLine*/ true , /*ensureUseStrict*/ true ) ;
7104+ writeLine ( ) ;
7105+ write ( `var __moduleName = ${ contextObjectForFile } && ${ contextObjectForFile } .id;` ) ;
7106+ writeLine ( ) ;
70927107 emitEmitHelpers ( node ) ;
70937108 emitCaptureThisForNodeIfNecessary ( node ) ;
70947109 emitSystemModuleBody ( node , dependencyGroups , startIndex ) ;
0 commit comments