Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 71e2939

Browse files
committed
experimental exports form in system register
1 parent 8358e27 commit 71e2939

40 files changed

+653
-3
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ coverage
66
npm-debug.log
77
.lvimrc
88
dist
9-
test/fixtures/register-modules

core/common.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function fileUrlToPath (fileUrl) {
2626
if (fileUrl.substr(0, 7) !== 'file://')
2727
throw new RangeError(fileUrl + ' is not a valid file url');
2828
if (isWindows)
29-
return fileUrl.substr(8).replace(/\//g, '/');
29+
return fileUrl.substr(8).replace(/\\/g, '/');
3030
else
3131
return fileUrl.substr(7);
3232
}

core/register-loader.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ function registerDeclarative (loader, load, link, declare) {
339339
if (locked)
340340
return;
341341

342-
if (typeof name == 'object') {
342+
if (typeof name === 'object') {
343343
for (var p in name)
344344
if (p !== '__useDefault')
345345
moduleObj[p] = name[p];
@@ -359,6 +359,8 @@ function registerDeclarative (loader, load, link, declare) {
359359
if (typeof declared !== 'function') {
360360
link.setters = declared.setters;
361361
link.execute = declared.execute;
362+
if (declared.exports)
363+
link.moduleObj = moduleObj = declared.exports;
362364
}
363365
else {
364366
link.setters = [];

test/fixtures/register-modules/_a.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
System.register(['./_b.js', './_d.js', './_g.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var a;
5+
return {
6+
setters: [function (_bJs) {
7+
var _exportObj = {};
8+
_exportObj.b = _bJs.b;
9+
10+
_export(_exportObj);
11+
}, function (_dJs) {
12+
var _exportObj2 = {};
13+
_exportObj2.d = _dJs.d;
14+
15+
_export(_exportObj2);
16+
}, function (_gJs) {
17+
var _exportObj3 = {};
18+
_exportObj3.g = _gJs.g;
19+
20+
_export(_exportObj3);
21+
}],
22+
execute: function () {
23+
_export('a', a = 'a');
24+
25+
_export('a', a);
26+
}
27+
};
28+
});

test/fixtures/register-modules/_b.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
System.register(['./_c.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var b;
5+
return {
6+
setters: [function (_cJs) {
7+
var _exportObj = {};
8+
_exportObj.c = _cJs.c;
9+
10+
_export(_exportObj);
11+
}],
12+
execute: function () {
13+
_export('b', b = 'b');
14+
15+
_export('b', b);
16+
}
17+
};
18+
});

test/fixtures/register-modules/_c.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
System.register(['./_d.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var c;
5+
return {
6+
setters: [function (_dJs) {
7+
var _exportObj = {};
8+
_exportObj.d = _dJs.d;
9+
10+
_export(_exportObj);
11+
}],
12+
execute: function () {
13+
_export('c', c = 'c');
14+
15+
_export('c', c);
16+
}
17+
};
18+
});

test/fixtures/register-modules/_d.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
System.register([], function (_export, _context) {
2+
"use strict";
3+
4+
var d;
5+
return {
6+
setters: [],
7+
execute: function () {
8+
_export('d', d = 'd');
9+
10+
_export('d', d);
11+
}
12+
};
13+
});

test/fixtures/register-modules/_e.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
System.register(['./_c.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var e;
5+
return {
6+
setters: [function (_cJs) {
7+
var _exportObj = {};
8+
_exportObj.c = _cJs.c;
9+
10+
_export(_exportObj);
11+
}],
12+
execute: function () {
13+
_export('e', e = 'e');
14+
15+
_export('e', e);
16+
}
17+
};
18+
});

test/fixtures/register-modules/_f.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
System.register(['./_g.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var f;
5+
return {
6+
setters: [function (_gJs) {
7+
var _exportObj = {};
8+
_exportObj.g = _gJs.g;
9+
10+
_export(_exportObj);
11+
}],
12+
execute: function () {
13+
_export('f', f = 'f');
14+
15+
_export('f', f);
16+
}
17+
};
18+
});

test/fixtures/register-modules/_g.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
System.register([], function (_export, _context) {
2+
"use strict";
3+
4+
var g;
5+
return {
6+
setters: [],
7+
execute: function () {
8+
_export('g', g = 'g');
9+
10+
_export('g', g);
11+
}
12+
};
13+
});

test/fixtures/register-modules/_h.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
System.register(['./_a.js', './_i.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var h;
5+
return {
6+
setters: [function (_aJs) {
7+
var _exportObj = {};
8+
_exportObj.a = _aJs.a;
9+
10+
_export(_exportObj);
11+
}, function (_iJs) {
12+
var _exportObj2 = {};
13+
_exportObj2.i = _iJs.i;
14+
15+
_export(_exportObj2);
16+
}],
17+
execute: function () {
18+
_export('h', h = 'h');
19+
20+
_export('h', h);
21+
}
22+
};
23+
});

test/fixtures/register-modules/_i.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
System.register(['./_b.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var i;
5+
return {
6+
setters: [function (_bJs) {
7+
var _exportObj = {};
8+
_exportObj.b = _bJs.b;
9+
10+
_export(_exportObj);
11+
}],
12+
execute: function () {
13+
_export('i', i = 'i');
14+
15+
_export('i', i);
16+
}
17+
};
18+
});

test/fixtures/register-modules/a.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
System.register(['./b.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var a;
5+
return {
6+
setters: [function (_bJs) {
7+
var _exportObj = {};
8+
_exportObj.b = _bJs.b;
9+
10+
_export(_exportObj);
11+
}],
12+
execute: function () {
13+
_export('a', a = 'a');
14+
15+
_export('a', a);
16+
}
17+
};
18+
});

test/fixtures/register-modules/b.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
System.register([], function (_export, _context) {
2+
"use strict";
3+
4+
var b;
5+
return {
6+
setters: [],
7+
execute: function () {
8+
_export('b', b = 'b');
9+
10+
_export('b', b);
11+
}
12+
};
13+
});

test/fixtures/register-modules/c.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
System.register(['./a.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var c;
5+
return {
6+
setters: [function (_aJs) {
7+
var _exportObj = {};
8+
_exportObj.a = _aJs.a;
9+
_exportObj.b = _aJs.b;
10+
11+
_export(_exportObj);
12+
}],
13+
execute: function () {
14+
_export('c', c = 'c');
15+
16+
_export('c', c);
17+
}
18+
};
19+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
System.register(['./circular2.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var fn2, variable2, variable1, output;
5+
function fn1() {
6+
_export('output', output = variable2);
7+
}
8+
9+
return {
10+
exports: {
11+
fn1: fn1,
12+
variable1: undefined,
13+
output: undefined,
14+
output2: undefined
15+
},
16+
setters: [function (_circular2Js) {
17+
fn2 = _circular2Js.fn2;
18+
variable2 = _circular2Js.variable2;
19+
var _exportObj = {};
20+
_exportObj.output2 = _circular2Js.output;
21+
22+
_export(_exportObj);
23+
}],
24+
execute: function () {
25+
_export('variable1', variable1 = 'test circular 1');
26+
27+
_export('variable1', variable1);
28+
29+
fn2();
30+
31+
_export('output', output);
32+
}
33+
};
34+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
System.register(['./circular1.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var fn1, variable1, variable2, output;
5+
function fn2() {
6+
_export('output', output = variable1);
7+
}
8+
9+
_export('fn2', fn2);
10+
11+
return {
12+
setters: [function (_circular1Js) {
13+
fn1 = _circular1Js.fn1;
14+
variable1 = _circular1Js.variable1;
15+
var _exportObj = {};
16+
_exportObj.output1 = _circular1Js.output;
17+
18+
_export(_exportObj);
19+
}],
20+
execute: function () {
21+
_export('variable2', variable2 = 'test circular 2');
22+
23+
_export('variable2', variable2);
24+
25+
fn1();
26+
27+
_export('output', output);
28+
}
29+
};
30+
});
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
System.register([], function (_export, _context) {
2+
"use strict";
3+
4+
return {
5+
setters: [],
6+
execute: function () {
7+
throw 'dep error';
8+
}
9+
};
10+
});
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
System.register(['./es6-dep.js'], function (_export, _context) {
2+
"use strict";
3+
4+
var p;
5+
return {
6+
setters: [function (_es6DepJs) {
7+
p = _es6DepJs.p;
8+
}],
9+
execute: function () {}
10+
};
11+
});
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
System.register([], function (_export, _context) {
2+
"use strict";
3+
4+
var p;
5+
return {
6+
setters: [],
7+
execute: function () {
8+
_export('p', p = 'p');
9+
10+
_export('p', p);
11+
}
12+
};
13+
});

0 commit comments

Comments
 (0)