Skip to content

Commit ea10692

Browse files
committed
Switch to ES6 modules.
1 parent e1788f5 commit ea10692

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

demo/src/class.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
define(['es6!src/sum'], (sum) => {
2-
console.log( sum(1,2) );
1+
import sum from 'es6!src/sum';
32

4-
class A {
5-
constructor(a) {
6-
console.log('Hello ' + a);
7-
}
3+
console.log( sum(1,2) );
4+
5+
class A {
6+
constructor(a) {
7+
console.log('Hello ' + a);
88
}
9+
}
910

10-
new A('world!');
11-
});
11+
new A('world!');

demo/src/sum.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
define(() => {
2-
return (a, b) => a + b;
3-
});
1+
export default (a, b) => a + b;

es6.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
var getXhr, fetchText, _buildMap = {};
1+
var fetchText, _buildMap = {};
22

33
if (typeof window !== "undefined" && window.navigator && window.document) {
4-
getXhr = function () {
5-
return new XMLHttpRequest();
6-
};
7-
84
fetchText = function (url, callback) {
9-
var xhr = getXhr();
5+
var xhr = new XMLHttpRequest();
106
xhr.open('GET', url, true);
117
xhr.onreadystatechange = function (evt) {
128
//Do not explicitly handle errors, those should be
@@ -17,7 +13,6 @@ if (typeof window !== "undefined" && window.navigator && window.document) {
1713
};
1814
xhr.send(null);
1915
};
20-
2116
} else if (typeof process !== "undefined" &&
2217
process.versions &&
2318
!!process.versions.node) {
@@ -31,11 +26,11 @@ if (typeof window !== "undefined" && window.navigator && window.document) {
3126
define(['babel'], function(babel) {
3227
return {
3328
load: function (name, req, onload, config) {
34-
var url = req.toUrl(name + '.js'),
35-
code;
29+
var url = req.toUrl(name + '.js');
3630

3731
fetchText(url, function (text) {
38-
code = babel.transform(text, {
32+
var code = babel.transform(text, {
33+
modules: 'amd',
3934
sourceMap: 'inline'
4035
}).code;
4136

0 commit comments

Comments
 (0)