Skip to content

Commit ae0f8a9

Browse files
committed
Merge pull request microsoft#7646 from Microsoft/system-transforms
fix a few issues in the emit of System modules
2 parents 1b24d47 + c4ecdd8 commit ae0f8a9

30 files changed

Lines changed: 390 additions & 330 deletions

src/compiler/printer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ const _super = (function (geti, seti) {
245245
currentFileIdentifiers = node.identifiers;
246246
sourceMap.setSourceFile(node);
247247
comments.setSourceFile(node);
248-
emitWorker(node);
248+
emitNodeWithNotificationOption(node, emitWorker);
249249
return node;
250250
}
251251

src/compiler/transformers/module/system.ts

Lines changed: 118 additions & 61 deletions
Large diffs are not rendered by default.

src/compiler/transformers/ts.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,25 +2129,27 @@ namespace ts {
21292129
// ...
21302130
// })(x || (x = {}));
21312131
statements.push(
2132-
createStatement(
2133-
createCall(
2134-
createParen(
2135-
createFunctionExpression(
2132+
setOriginalNode(
2133+
createStatement(
2134+
createCall(
2135+
createParen(
2136+
createFunctionExpression(
21362137
/*asteriskToken*/ undefined,
21372138
/*name*/ undefined,
2138-
[createParameter(currentNamespaceLocalName)],
2139-
transformEnumBody(node)
2140-
)
2141-
),
2142-
[createLogicalOr(
2143-
name,
2144-
createAssignment(
2139+
[createParameter(currentNamespaceLocalName)],
2140+
transformEnumBody(node)
2141+
)
2142+
),
2143+
[createLogicalOr(
21452144
name,
2146-
createObjectLiteral()
2147-
)
2148-
)]
2149-
),
2150-
location
2145+
createAssignment(
2146+
name,
2147+
createObjectLiteral()
2148+
)
2149+
)]
2150+
),
2151+
location
2152+
), node
21512153
)
21522154
);
21532155

tests/baselines/reference/aliasesInSystemModule1.js

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

1818

1919
//// [aliasesInSystemModule1.js]
20-
System.register(['foo'], function(exports_1, context_1) {
20+
System.register(["foo"], function (exports_1, context_1) {
2121
"use strict";
2222
var __moduleName = context_1 && context_1.id;
23-
var alias;
24-
var cls, cls2, x, y, z, M;
23+
var alias, cls, cls2, x, y, z, M;
2524
return {
26-
setters:[
25+
setters: [
2726
function (alias_1) {
2827
alias = alias_1;
29-
}],
30-
execute: function() {
28+
}
29+
],
30+
execute: function () {
3131
cls = alias.Class;
3232
exports_1("cls2", cls2 = alias.Class);
3333
x = new alias.Class();
@@ -40,5 +40,5 @@ System.register(['foo'], function(exports_1, context_1) {
4040
var z = new cls2();
4141
})(M || (M = {}));
4242
}
43-
}
43+
};
4444
});

tests/baselines/reference/aliasesInSystemModule2.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ module M {
1616
}
1717

1818
//// [aliasesInSystemModule2.js]
19-
System.register(["foo"], function(exports_1, context_1) {
19+
System.register(["foo"], function (exports_1, context_1) {
2020
"use strict";
2121
var __moduleName = context_1 && context_1.id;
22-
var foo_1;
23-
var cls, cls2, x, y, z, M;
22+
var foo_1, cls, cls2, x, y, z, M;
2423
return {
25-
setters:[
26-
function (foo_1_1) {
27-
foo_1 = foo_1_1;
28-
}],
29-
execute: function() {
24+
setters: [
25+
function (_1) {
26+
foo_1 = _1;
27+
}
28+
],
29+
execute: function () {
3030
cls = foo_1.alias.Class;
3131
exports_1("cls2", cls2 = foo_1.alias.Class);
3232
x = new foo_1.alias.Class();
@@ -39,5 +39,5 @@ System.register(["foo"], function(exports_1, context_1) {
3939
var z = new cls2();
4040
})(M || (M = {}));
4141
}
42-
}
42+
};
4343
});

tests/baselines/reference/systemExportAssignment.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import * as a from "a";
1010

1111

1212
//// [b.js]
13-
System.register([], function(exports_1, context_1) {
13+
System.register([], function (exports_1, context_1) {
1414
"use strict";
1515
var __moduleName = context_1 && context_1.id;
1616
return {
17-
setters:[],
18-
execute: function() {
17+
setters: [],
18+
execute: function () {
1919
}
20-
}
20+
};
2121
});

tests/baselines/reference/systemExportAssignment2.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ import * as a from "a";
1010

1111

1212
//// [a.js]
13-
System.register([], function(exports_1, context_1) {
13+
System.register([], function (exports_1, context_1) {
1414
"use strict";
1515
var __moduleName = context_1 && context_1.id;
1616
var a;
1717
return {
18-
setters:[],
19-
execute: function() {
18+
setters: [],
19+
execute: function () {
2020
a = 10;
2121
}
22-
}
22+
};
2323
});
2424
//// [b.js]
25-
System.register([], function(exports_1, context_1) {
25+
System.register([], function (exports_1, context_1) {
2626
"use strict";
2727
var __moduleName = context_1 && context_1.id;
2828
return {
29-
setters:[],
30-
execute: function() {
29+
setters: [],
30+
execute: function () {
3131
}
32-
}
32+
};
3333
});

tests/baselines/reference/systemExportAssignment3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import * as a from "a";
1212

1313

1414
//// [b.js]
15-
System.register([], function(exports_1, context_1) {
15+
System.register([], function (exports_1, context_1) {
1616
"use strict";
1717
var __moduleName = context_1 && context_1.id;
1818
return {
19-
setters:[],
20-
execute: function() {
19+
setters: [],
20+
execute: function () {
2121
}
22-
}
22+
};
2323
});

tests/baselines/reference/systemModule1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
export var x = 1;
44

55
//// [systemModule1.js]
6-
System.register([], function(exports_1, context_1) {
6+
System.register([], function (exports_1, context_1) {
77
"use strict";
88
var __moduleName = context_1 && context_1.id;
99
var x;
1010
return {
11-
setters:[],
12-
execute: function() {
11+
setters: [],
12+
execute: function () {
1313
exports_1("x", x = 1);
1414
}
15-
}
15+
};
1616
});

tests/baselines/reference/systemModule10.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,26 @@ export {n2}
1010
export {n2 as n3}
1111

1212
//// [systemModule10.js]
13-
System.register(['file1', 'file2'], function(exports_1, context_1) {
13+
System.register(["file1", "file2"], function (exports_1, context_1) {
1414
"use strict";
1515
var __moduleName = context_1 && context_1.id;
1616
var file1_1, n2;
1717
return {
18-
setters:[
19-
function (file1_1_1) {
20-
file1_1 = file1_1_1;
18+
setters: [
19+
function (_1) {
20+
file1_1 = _1;
2121
},
2222
function (n2_1) {
2323
n2 = n2_1;
24-
}],
25-
execute: function() {
24+
}
25+
],
26+
execute: function () {
2627
exports_1("x", file1_1.x);
2728
exports_1("y", file1_1.x);
2829
exports_1("n", file1_1["default"]);
2930
exports_1("n1", file1_1["default"]);
3031
exports_1("n2", n2);
3132
exports_1("n3", n2);
3233
}
33-
}
34+
};
3435
});

0 commit comments

Comments
 (0)