Skip to content

Commit 7d11859

Browse files
committed
set __moduleName from context.id argument
1 parent 0981719 commit 7d11859

Some content is hidden

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

52 files changed

+206
-117
lines changed

src/compiler/emitter.ts

Lines changed: 7 additions & 1 deletion
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,9 +7097,11 @@ const _super = (function (geti, seti) {
70937097

70947098
write(text);
70957099
}
7096-
write(`], function(${exportFunctionForFile}) {`);
7100+
write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`);
70977101
writeLine();
70987102
increaseIndent();
7103+
write(`var __moduleName = ${contextObjectForFile}.id;`);
7104+
writeLine();
70997105
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
71007106
emitEmitHelpers(node);
71017107
emitCaptureThisForNodeIfNecessary(node);

tests/baselines/reference/aliasesInSystemModule1.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module M {
1717

1818

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

tests/baselines/reference/aliasesInSystemModule2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module M {
1616
}
1717

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

tests/baselines/reference/allowSyntheticDefaultImports2.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export class Foo {
1010
}
1111

1212
//// [b.js]
13-
System.register([], function(exports_1) {
13+
System.register([], function(exports_1, context_1) {
14+
var __moduleName = context_1.id;
1415
"use strict";
1516
var Foo;
1617
return {
@@ -26,7 +27,8 @@ 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) {
31+
var __moduleName = context_1.id;
3032
"use strict";
3133
var b_1;
3234
var x;

tests/baselines/reference/allowSyntheticDefaultImports3.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export class Foo {
1111

1212

1313
//// [b.js]
14-
System.register([], function(exports_1) {
14+
System.register([], function(exports_1, context_1) {
15+
var __moduleName = context_1.id;
1516
"use strict";
1617
var Foo;
1718
return {
@@ -27,7 +28,8 @@ 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) {
32+
var __moduleName = context_1.id;
3133
"use strict";
3234
var b_1;
3335
var x;

tests/baselines/reference/allowSyntheticDefaultImports5.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ 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) {
16+
var __moduleName = context_1.id;
1617
"use strict";
1718
var b_1;
1819
var x;

tests/baselines/reference/allowSyntheticDefaultImports6.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ 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) {
16+
var __moduleName = context_1.id;
1617
"use strict";
1718
var b_1;
1819
var x;

tests/baselines/reference/anonymousDefaultExportsSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ 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) {
11+
var __moduleName = context_1.id;
1112
"use strict";
1213
var default_1;
1314
return {
@@ -20,7 +21,8 @@ System.register([], function(exports_1) {
2021
}
2122
});
2223
//// [b.js]
23-
System.register([], function(exports_1) {
24+
System.register([], function(exports_1, context_1) {
25+
var __moduleName = context_1.id;
2426
"use strict";
2527
function default_1() { }
2628
exports_1("default", default_1);

tests/baselines/reference/capturedLetConstInLoop4.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ 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) {
148+
var __moduleName = context_1.id;
148149
"use strict";
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

tests/baselines/reference/decoratedDefaultExportsGetExportedSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ 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) {
17+
var __moduleName = context_1.id;
1718
"use strict";
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;
@@ -35,7 +36,8 @@ System.register([], function(exports_1) {
3536
}
3637
});
3738
//// [b.js]
38-
System.register([], function(exports_1) {
39+
System.register([], function(exports_1, context_1) {
40+
var __moduleName = context_1.id;
3941
"use strict";
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;

tests/baselines/reference/deduplicateImportsInSystem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ 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) {
13+
var __moduleName = context_1.id;
1314
"use strict";
1415
var f1_1, f2_1, f3_1, f2_2, f2_3, f1_2;
1516
return {

tests/baselines/reference/defaultExportsGetExportedSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default function foo() {}
88

99

1010
//// [a.js]
11-
System.register([], function(exports_1) {
11+
System.register([], function(exports_1, context_1) {
12+
var __moduleName = context_1.id;
1213
"use strict";
1314
var Foo;
1415
return {
@@ -21,7 +22,8 @@ System.register([], function(exports_1) {
2122
}
2223
});
2324
//// [b.js]
24-
System.register([], function(exports_1) {
25+
System.register([], function(exports_1, context_1) {
26+
var __moduleName = context_1.id;
2527
"use strict";
2628
function foo() { }
2729
exports_1("default", foo);

tests/baselines/reference/es5-system.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export default class A
1515

1616

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

tests/baselines/reference/exportNonInitializedVariablesSystem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ 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) {
39+
var __moduleName = context_1.id;
3940
"use strict";
4041
var a, b, c, d, A, e, f, B, C, a1, b1, c1, d1, D, e1, f1, g1, h1;
4142
return {

tests/baselines/reference/exportStarForValues10.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ 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) {
17+
var __moduleName = context_1.id;
1718
"use strict";
1819
var v;
1920
return {
@@ -24,7 +25,8 @@ System.register([], function(exports_1) {
2425
}
2526
});
2627
//// [file1.js]
27-
System.register([], function(exports_1) {
28+
System.register([], function(exports_1, context_1) {
29+
var __moduleName = context_1.id;
2830
"use strict";
2931
return {
3032
setters:[],
@@ -33,7 +35,8 @@ System.register([], function(exports_1) {
3335
}
3436
});
3537
//// [file2.js]
36-
System.register(["file0"], function(exports_1) {
38+
System.register(["file0"], function(exports_1, context_1) {
39+
var __moduleName = context_1.id;
3740
"use strict";
3841
var x;
3942
function exportStar_1(m) {

tests/baselines/reference/exportStarForValues6.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ 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) {
13+
var __moduleName = context_1.id;
1314
"use strict";
1415
return {
1516
setters:[],
@@ -18,7 +19,8 @@ System.register([], function(exports_1) {
1819
}
1920
});
2021
//// [file2.js]
21-
System.register([], function(exports_1) {
22+
System.register([], function(exports_1, context_1) {
23+
var __moduleName = context_1.id;
2224
"use strict";
2325
var x;
2426
return {

tests/baselines/reference/exportStarForValuesInSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ 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) {
13+
var __moduleName = context_1.id;
1314
"use strict";
1415
return {
1516
setters:[],
@@ -18,7 +19,8 @@ System.register([], function(exports_1) {
1819
}
1920
});
2021
//// [file2.js]
21-
System.register([], function(exports_1) {
22+
System.register([], function(exports_1, context_1) {
23+
var __moduleName = context_1.id;
2224
"use strict";
2325
var x;
2426
return {

tests/baselines/reference/isolatedModulesPlainFile-System.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ run(1);
55

66

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

tests/baselines/reference/modulePrologueSystem.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
export class Foo {}
55

66
//// [modulePrologueSystem.js]
7-
System.register([], function(exports_1) {
7+
System.register([], function(exports_1, context_1) {
8+
var __moduleName = context_1.id;
89
"use strict";
910
var Foo;
1011
return {

tests/baselines/reference/outFilerootDirModuleNamesSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ 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) {
15+
var __moduleName = context_1.id;
1516
"use strict";
1617
var a_1;
1718
function foo() { new a_1.default(); }
@@ -25,7 +26,8 @@ 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) {
30+
var __moduleName = context_2.id;
2931
"use strict";
3032
var b_1;
3133
var Foo;

tests/baselines/reference/outModuleConcatSystem.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ 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) {
18+
var __moduleName = context_1.id;
1819
"use strict";
1920
var A;
2021
return {
@@ -29,7 +30,8 @@ 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) {
34+
var __moduleName = context_2.id;
3335
"use strict";
3436
var a_1;
3537
var B;

tests/baselines/reference/outModuleConcatSystem.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)