Skip to content

Commit 3cad12b

Browse files
committed
Initial commit
0 parents  commit 3cad12b

File tree

8 files changed

+159
-0
lines changed

8 files changed

+159
-0
lines changed

babel-4.6.6.min.js

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bower.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "requirejs-babel",
3+
"version": "0.0.0",
4+
"authors": [
5+
"mikach <[email protected]>"
6+
],
7+
"description": "An AMD loader plugin for Babel",
8+
"main": "es6.js",
9+
"moduleType": [
10+
"amd"
11+
],
12+
"keywords": [
13+
"es6",
14+
"esnext",
15+
"babel"
16+
],
17+
"license": "MIT",
18+
"ignore": [
19+
"**/.*",
20+
"node_modules",
21+
"bower_components",
22+
"test",
23+
"tests"
24+
]
25+
}

demo/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
</head>
7+
<body>
8+
9+
<script src="libs/requirejs.min.js"></script>
10+
<script>
11+
requirejs.config({
12+
paths: {
13+
'es6': '../es6',
14+
'babel': '../babel-4.6.6.min'
15+
}
16+
});
17+
18+
require(['es6!src/main']);
19+
</script
20+
</body>
21+
</html>

demo/libs/requirejs.min.js

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/src/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
define(['es6!src/sum'], function(sum) {
2+
console.log( sum(1,2) );
3+
4+
class A {
5+
constructor(a) {
6+
console.log('Hello ' + a);
7+
}
8+
}
9+
10+
new A('world!');
11+
});

demo/src/sum.js

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

es6.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var fetchText = function (url, callback) {
2+
var xhr = new XMLHttpRequest();
3+
xhr.open('GET', url, true);
4+
xhr.onreadystatechange = function (evt) {
5+
//Do not explicitly handle errors, those should be
6+
//visible via console output in the browser.
7+
if (xhr.readyState === 4) {
8+
callback(xhr.responseText);
9+
}
10+
};
11+
xhr.send(null);
12+
};
13+
14+
define(['babel'], function(babel) {
15+
return {
16+
load: function (name, req, onload, config) {
17+
var url = req.toUrl(name + '.js'),
18+
code;
19+
20+
fetchText(url, function (text) {
21+
code = babel.transform(text).code;
22+
onload.fromText(code);
23+
});
24+
}
25+
}
26+
});

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "requirejs-babel",
3+
"version": "0.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "MIT"
11+
}

0 commit comments

Comments
 (0)