Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// =>
// var x;... exporter("x", x = 1)
let exportFunctionForFile: string;
let contextObjectForFile: string;

let generatedNameSet: Map<string>;
let nodeToGeneratedName: string[];
Expand Down Expand Up @@ -557,6 +558,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
currentText = undefined;
currentLineMap = undefined;
exportFunctionForFile = undefined;
contextObjectForFile = undefined;
generatedNameSet = undefined;
nodeToGeneratedName = undefined;
computedPropertyNamesToGeneratedNames = undefined;
Expand Down Expand Up @@ -585,6 +587,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
currentText = sourceFile.text;
currentLineMap = getLineStarts(sourceFile);
exportFunctionForFile = undefined;
contextObjectForFile = undefined;
isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"];
renamedDependencies = sourceFile.renamedDependencies;
currentFileIdentifiers = sourceFile.identifiers;
Expand Down Expand Up @@ -7058,6 +7061,7 @@ const _super = (function (geti, seti) {
Debug.assert(!exportFunctionForFile);
// make sure that name of 'exports' function does not conflict with existing identifiers
exportFunctionForFile = makeUniqueName("exports");
contextObjectForFile = makeUniqueName("context");
writeLine();
write("System.register(");
writeModuleName(node, emitRelativePathAsModuleName);
Expand Down Expand Up @@ -7093,10 +7097,13 @@ const _super = (function (geti, seti) {

write(text);
}
write(`], function(${exportFunctionForFile}) {`);
write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`);
writeLine();
increaseIndent();
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
writeLine();
write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`);
writeLine();
emitEmitHelpers(node);
emitCaptureThisForNodeIfNecessary(node);
emitSystemModuleBody(node, dependencyGroups, startIndex);
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/aliasesInSystemModule1.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ module M {


//// [aliasesInSystemModule1.js]
System.register(['foo'], function(exports_1) {
System.register(['foo'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var alias;
var cls, cls2, x, y, z, M;
return {
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/aliasesInSystemModule2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module M {
}

//// [aliasesInSystemModule2.js]
System.register(["foo"], function(exports_1) {
System.register(["foo"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var foo_1;
var cls, cls2, x, y, z, M;
return {
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/allowSyntheticDefaultImports2.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ export class Foo {
}

//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var Foo;
return {
setters:[],
Expand All @@ -26,8 +27,9 @@ System.register([], function(exports_1) {
}
});
//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var b_1;
var x;
return {
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/allowSyntheticDefaultImports3.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export class Foo {


//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var Foo;
return {
setters:[],
Expand All @@ -27,8 +28,9 @@ System.register([], function(exports_1) {
}
});
//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var b_1;
var x;
return {
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/allowSyntheticDefaultImports5.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export var x = new Foo();


//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var b_1;
var x;
return {
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/allowSyntheticDefaultImports6.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export var x = new Foo();


//// [a.js]
System.register(["./b"], function(exports_1) {
System.register(["./b"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var b_1;
var x;
return {
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/anonymousDefaultExportsSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default class {}
export default function() {}

//// [a.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var default_1;
return {
setters:[],
Expand All @@ -20,8 +21,9 @@ System.register([], function(exports_1) {
}
});
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
function default_1() { }
exports_1("default", default_1);
return {
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/capturedLetConstInLoop4.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ for (const y = 0; y < 1;) {


//// [capturedLetConstInLoop4.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var v0, v00, v1, v2, v3, v4, v5, v6, v7, v8, v0_c, v00_c, v1_c, v2_c, v3_c, v4_c, v5_c, v6_c, v7_c, v8_c;
//======let
function exportedFoo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ var decorator: ClassDecorator;
export default class {}

//// [a.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
Expand All @@ -35,8 +36,9 @@ System.register([], function(exports_1) {
}
});
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/deduplicateImportsInSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {F} from 'f1';
console.log(A + B + C + D + E + F)

//// [deduplicateImportsInSystem.js]
System.register(["f1", "f2", "f3"], function(exports_1) {
System.register(["f1", "f2", "f3"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var f1_1, f2_1, f3_1, f2_2, f2_3, f1_2;
return {
setters:[
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/defaultExportsGetExportedSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ export default function foo() {}


//// [a.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var Foo;
return {
setters:[],
Expand All @@ -21,8 +22,9 @@ System.register([], function(exports_1) {
}
});
//// [b.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
function foo() { }
exports_1("default", foo);
return {
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/es5-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export default class A


//// [es5-system.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var A;
return {
setters:[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export let h1: D = new D;


//// [exportNonInitializedVariablesSystem.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var a, b, c, d, A, e, f, B, C, a1, b1, c1, d1, D, e1, f1, g1, h1;
return {
setters:[],
Expand Down
9 changes: 6 additions & 3 deletions tests/baselines/reference/exportStarForValues10.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export * from "file1";
var x = 1;

//// [file0.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var v;
return {
setters:[],
Expand All @@ -24,17 +25,19 @@ System.register([], function(exports_1) {
}
});
//// [file1.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters:[],
execute: function() {
}
}
});
//// [file2.js]
System.register(["file0"], function(exports_1) {
System.register(["file0"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var x;
function exportStar_1(m) {
var exports = {};
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/exportStarForValues6.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ export * from "file1"
export var x = 1;

//// [file1.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters:[],
execute: function() {
}
}
});
//// [file2.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var x;
return {
setters:[],
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/exportStarForValuesInSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ export * from "file1"
var x = 1;

//// [file1.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters:[],
execute: function() {
}
}
});
//// [file2.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var x;
return {
setters:[],
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/isolatedModulesPlainFile-System.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ run(1);


//// [isolatedModulesPlainFile-System.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters:[],
execute: function() {
Expand Down
3 changes: 2 additions & 1 deletion tests/baselines/reference/modulePrologueSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
export class Foo {}

//// [modulePrologueSystem.js]
System.register([], function(exports_1) {
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var Foo;
return {
setters:[],
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/outFilerootDirModuleNamesSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export default function foo() { new Foo(); }


//// [output.js]
System.register("b", ["a"], function(exports_1) {
System.register("b", ["a"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var a_1;
function foo() { new a_1.default(); }
exports_1("default", foo);
Expand All @@ -25,8 +26,9 @@ System.register("b", ["a"], function(exports_1) {
}
}
});
System.register("a", ["b"], function(exports_2) {
System.register("a", ["b"], function(exports_2, context_2) {
"use strict";
var __moduleName = context_2 && context_2.id;
var b_1;
var Foo;
return {
Expand Down
6 changes: 4 additions & 2 deletions tests/baselines/reference/outModuleConcatSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
System.register("ref/a", [], function(exports_1) {
System.register("ref/a", [], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var A;
return {
setters:[],
Expand All @@ -29,8 +30,9 @@ System.register("ref/a", [], function(exports_1) {
}
}
});
System.register("b", ["ref/a"], function(exports_2) {
System.register("b", ["ref/a"], function(exports_2, context_2) {
"use strict";
var __moduleName = context_2 && context_2.id;
var a_1;
var B;
return {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/outModuleConcatSystem.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading