Skip to content

Commit 94fe3e0

Browse files
committed
set __moduleName from context.id argument
1 parent e954929 commit 94fe3e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+213
-119
lines changed

src/compiler/emitter.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -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);

tests/baselines/reference/aliasesInSystemModule1.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ module M {
1717

1818

1919
//// [aliasesInSystemModule1.js]
20-
System.register(['foo'], function(exports_1) {
20+
System.register(['foo'], function(exports_1, context_1) {
2121
"use strict";
22+
var __moduleName = context_1 && context_1.id;
2223
var alias;
2324
var cls, cls2, x, y, z, M;
2425
return {

tests/baselines/reference/aliasesInSystemModule2.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ module M {
1616
}
1717

1818
//// [aliasesInSystemModule2.js]
19-
System.register(["foo"], function(exports_1) {
19+
System.register(["foo"], function(exports_1, context_1) {
2020
"use strict";
21+
var __moduleName = context_1 && context_1.id;
2122
var foo_1;
2223
var cls, cls2, x, y, z, M;
2324
return {

tests/baselines/reference/allowSyntheticDefaultImports2.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export class Foo {
1010
}
1111

1212
//// [b.js]
13-
System.register([], function(exports_1) {
13+
System.register([], function(exports_1, context_1) {
1414
"use strict";
15+
var __moduleName = context_1 && context_1.id;
1516
var Foo;
1617
return {
1718
setters:[],
@@ -26,8 +27,9 @@ System.register([], function(exports_1) {
2627
}
2728
});
2829
//// [a.js]
29-
System.register(["./b"], function(exports_1) {
30+
System.register(["./b"], function(exports_1, context_1) {
3031
"use strict";
32+
var __moduleName = context_1 && context_1.id;
3133
var b_1;
3234
var x;
3335
return {

tests/baselines/reference/allowSyntheticDefaultImports3.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export class Foo {
1111

1212

1313
//// [b.js]
14-
System.register([], function(exports_1) {
14+
System.register([], function(exports_1, context_1) {
1515
"use strict";
16+
var __moduleName = context_1 && context_1.id;
1617
var Foo;
1718
return {
1819
setters:[],
@@ -27,8 +28,9 @@ System.register([], function(exports_1) {
2728
}
2829
});
2930
//// [a.js]
30-
System.register(["./b"], function(exports_1) {
31+
System.register(["./b"], function(exports_1, context_1) {
3132
"use strict";
33+
var __moduleName = context_1 && context_1.id;
3234
var b_1;
3335
var x;
3436
return {

tests/baselines/reference/allowSyntheticDefaultImports5.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export var x = new Foo();
1212

1313

1414
//// [a.js]
15-
System.register(["./b"], function(exports_1) {
15+
System.register(["./b"], function(exports_1, context_1) {
1616
"use strict";
17+
var __moduleName = context_1 && context_1.id;
1718
var b_1;
1819
var x;
1920
return {

tests/baselines/reference/allowSyntheticDefaultImports6.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ export var x = new Foo();
1212

1313

1414
//// [a.js]
15-
System.register(["./b"], function(exports_1) {
15+
System.register(["./b"], function(exports_1, context_1) {
1616
"use strict";
17+
var __moduleName = context_1 && context_1.id;
1718
var b_1;
1819
var x;
1920
return {

tests/baselines/reference/anonymousDefaultExportsSystem.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export default class {}
77
export default function() {}
88

99
//// [a.js]
10-
System.register([], function(exports_1) {
10+
System.register([], function(exports_1, context_1) {
1111
"use strict";
12+
var __moduleName = context_1 && context_1.id;
1213
var default_1;
1314
return {
1415
setters:[],
@@ -20,8 +21,9 @@ System.register([], function(exports_1) {
2021
}
2122
});
2223
//// [b.js]
23-
System.register([], function(exports_1) {
24+
System.register([], function(exports_1, context_1) {
2425
"use strict";
26+
var __moduleName = context_1 && context_1.id;
2527
function default_1() { }
2628
exports_1("default", default_1);
2729
return {

tests/baselines/reference/capturedLetConstInLoop4.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ for (const y = 0; y < 1;) {
144144

145145

146146
//// [capturedLetConstInLoop4.js]
147-
System.register([], function(exports_1) {
147+
System.register([], function(exports_1, context_1) {
148148
"use strict";
149+
var __moduleName = context_1 && context_1.id;
149150
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;
150151
//======let
151152
function exportedFoo() {

tests/baselines/reference/decoratedDefaultExportsGetExportedSystem.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ var decorator: ClassDecorator;
1313
export default class {}
1414

1515
//// [a.js]
16-
System.register([], function(exports_1) {
16+
System.register([], function(exports_1, context_1) {
1717
"use strict";
18+
var __moduleName = context_1 && context_1.id;
1819
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
1920
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2021
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -35,8 +36,9 @@ System.register([], function(exports_1) {
3536
}
3637
});
3738
//// [b.js]
38-
System.register([], function(exports_1) {
39+
System.register([], function(exports_1, context_1) {
3940
"use strict";
41+
var __moduleName = context_1 && context_1.id;
4042
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
4143
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4244
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);

tests/baselines/reference/deduplicateImportsInSystem.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import {F} from 'f1';
99
console.log(A + B + C + D + E + F)
1010

1111
//// [deduplicateImportsInSystem.js]
12-
System.register(["f1", "f2", "f3"], function(exports_1) {
12+
System.register(["f1", "f2", "f3"], function(exports_1, context_1) {
1313
"use strict";
14+
var __moduleName = context_1 && context_1.id;
1415
var f1_1, f2_1, f3_1, f2_2, f2_3, f1_2;
1516
return {
1617
setters:[

tests/baselines/reference/defaultExportsGetExportedSystem.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export default function foo() {}
88

99

1010
//// [a.js]
11-
System.register([], function(exports_1) {
11+
System.register([], function(exports_1, context_1) {
1212
"use strict";
13+
var __moduleName = context_1 && context_1.id;
1314
var Foo;
1415
return {
1516
setters:[],
@@ -21,8 +22,9 @@ System.register([], function(exports_1) {
2122
}
2223
});
2324
//// [b.js]
24-
System.register([], function(exports_1) {
25+
System.register([], function(exports_1, context_1) {
2526
"use strict";
27+
var __moduleName = context_1 && context_1.id;
2628
function foo() { }
2729
exports_1("default", foo);
2830
return {

tests/baselines/reference/es5-system.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ export default class A
1515

1616

1717
//// [es5-system.js]
18-
System.register([], function(exports_1) {
18+
System.register([], function(exports_1, context_1) {
1919
"use strict";
20+
var __moduleName = context_1 && context_1.id;
2021
var A;
2122
return {
2223
setters:[],

tests/baselines/reference/exportNonInitializedVariablesSystem.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ export let h1: D = new D;
3535

3636

3737
//// [exportNonInitializedVariablesSystem.js]
38-
System.register([], function(exports_1) {
38+
System.register([], function(exports_1, context_1) {
3939
"use strict";
40+
var __moduleName = context_1 && context_1.id;
4041
var a, b, c, d, A, e, f, B, C, a1, b1, c1, d1, D, e1, f1, g1, h1;
4142
return {
4243
setters:[],

tests/baselines/reference/exportStarForValues10.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export * from "file1";
1313
var x = 1;
1414

1515
//// [file0.js]
16-
System.register([], function(exports_1) {
16+
System.register([], function(exports_1, context_1) {
1717
"use strict";
18+
var __moduleName = context_1 && context_1.id;
1819
var v;
1920
return {
2021
setters:[],
@@ -24,17 +25,19 @@ System.register([], function(exports_1) {
2425
}
2526
});
2627
//// [file1.js]
27-
System.register([], function(exports_1) {
28+
System.register([], function(exports_1, context_1) {
2829
"use strict";
30+
var __moduleName = context_1 && context_1.id;
2931
return {
3032
setters:[],
3133
execute: function() {
3234
}
3335
}
3436
});
3537
//// [file2.js]
36-
System.register(["file0"], function(exports_1) {
38+
System.register(["file0"], function(exports_1, context_1) {
3739
"use strict";
40+
var __moduleName = context_1 && context_1.id;
3841
var x;
3942
function exportStar_1(m) {
4043
var exports = {};

tests/baselines/reference/exportStarForValues6.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ export * from "file1"
99
export var x = 1;
1010

1111
//// [file1.js]
12-
System.register([], function(exports_1) {
12+
System.register([], function(exports_1, context_1) {
1313
"use strict";
14+
var __moduleName = context_1 && context_1.id;
1415
return {
1516
setters:[],
1617
execute: function() {
1718
}
1819
}
1920
});
2021
//// [file2.js]
21-
System.register([], function(exports_1) {
22+
System.register([], function(exports_1, context_1) {
2223
"use strict";
24+
var __moduleName = context_1 && context_1.id;
2325
var x;
2426
return {
2527
setters:[],

tests/baselines/reference/exportStarForValuesInSystem.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ export * from "file1"
99
var x = 1;
1010

1111
//// [file1.js]
12-
System.register([], function(exports_1) {
12+
System.register([], function(exports_1, context_1) {
1313
"use strict";
14+
var __moduleName = context_1 && context_1.id;
1415
return {
1516
setters:[],
1617
execute: function() {
1718
}
1819
}
1920
});
2021
//// [file2.js]
21-
System.register([], function(exports_1) {
22+
System.register([], function(exports_1, context_1) {
2223
"use strict";
24+
var __moduleName = context_1 && context_1.id;
2325
var x;
2426
return {
2527
setters:[],

tests/baselines/reference/isolatedModulesPlainFile-System.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ run(1);
55

66

77
//// [isolatedModulesPlainFile-System.js]
8-
System.register([], function(exports_1) {
8+
System.register([], function(exports_1, context_1) {
99
"use strict";
10+
var __moduleName = context_1 && context_1.id;
1011
return {
1112
setters:[],
1213
execute: function() {

tests/baselines/reference/modulePrologueSystem.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
export class Foo {}
55

66
//// [modulePrologueSystem.js]
7-
System.register([], function(exports_1) {
7+
System.register([], function(exports_1, context_1) {
88
"use strict";
9+
var __moduleName = context_1 && context_1.id;
910
var Foo;
1011
return {
1112
setters:[],

tests/baselines/reference/outFilerootDirModuleNamesSystem.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export default function foo() { new Foo(); }
1111

1212

1313
//// [output.js]
14-
System.register("b", ["a"], function(exports_1) {
14+
System.register("b", ["a"], function(exports_1, context_1) {
1515
"use strict";
16+
var __moduleName = context_1 && context_1.id;
1617
var a_1;
1718
function foo() { new a_1.default(); }
1819
exports_1("default", foo);
@@ -25,8 +26,9 @@ System.register("b", ["a"], function(exports_1) {
2526
}
2627
}
2728
});
28-
System.register("a", ["b"], function(exports_2) {
29+
System.register("a", ["b"], function(exports_2, context_2) {
2930
"use strict";
31+
var __moduleName = context_2 && context_2.id;
3032
var b_1;
3133
var Foo;
3234
return {

tests/baselines/reference/outModuleConcatSystem.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ var __extends = (this && this.__extends) || function (d, b) {
1414
function __() { this.constructor = d; }
1515
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1616
};
17-
System.register("ref/a", [], function(exports_1) {
17+
System.register("ref/a", [], function(exports_1, context_1) {
1818
"use strict";
19+
var __moduleName = context_1 && context_1.id;
1920
var A;
2021
return {
2122
setters:[],
@@ -29,8 +30,9 @@ System.register("ref/a", [], function(exports_1) {
2930
}
3031
}
3132
});
32-
System.register("b", ["ref/a"], function(exports_2) {
33+
System.register("b", ["ref/a"], function(exports_2, context_2) {
3334
"use strict";
35+
var __moduleName = context_2 && context_2.id;
3436
var a_1;
3537
var B;
3638
return {

tests/baselines/reference/outModuleConcatSystem.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)