Skip to content

Commit 80ce71a

Browse files
committed
Move the fetchText function to the module callback
1 parent 7ccb155 commit 80ce71a

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

es6.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,3 @@
1-
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
2-
var fetchText, _buildMap = {};
3-
4-
if (typeof window !== "undefined" && window.navigator && window.document) {
5-
fetchText = function (url, callback) {
6-
var xhr = new XMLHttpRequest();
7-
xhr.open('GET', url, true);
8-
xhr.onreadystatechange = function (evt) {
9-
//Do not explicitly handle errors, those should be
10-
//visible via console output in the browser.
11-
if (xhr.readyState === 4) {
12-
callback(xhr.responseText);
13-
}
14-
};
15-
xhr.send(null);
16-
};
17-
} else if (typeof process !== "undefined" &&
18-
process.versions &&
19-
!!process.versions.node) {
20-
//Using special require.nodeRequire, something added by r.js.
21-
fs = require.nodeRequire('fs');
22-
fetchText = function (path, callback) {
23-
callback(fs.readFileSync(path, 'utf8'));
24-
};
25-
}
26-
//>>excludeEnd('excludeBabel')
27-
281
define([
292
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
303
'babel', 'babel-plugin-module-resolver',
@@ -37,6 +10,31 @@ define([
3710
//>>excludeEnd('excludeBabel')
3811
) {
3912
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
13+
var fetchText, _buildMap = {};
14+
15+
if (typeof window !== 'undefined' && window.navigator && window.document) {
16+
fetchText = function (url, callback) {
17+
var xhr = new XMLHttpRequest();
18+
xhr.open('GET', url, true);
19+
xhr.onreadystatechange = function (evt) {
20+
//Do not explicitly handle errors, those should be
21+
//visible via console output in the browser.
22+
if (xhr.readyState === 4) {
23+
callback(xhr.responseText);
24+
}
25+
};
26+
xhr.send(null);
27+
};
28+
} else if (typeof process !== 'undefined' &&
29+
process.versions &&
30+
!!process.versions.node) {
31+
//Using special require.nodeRequire, something added by r.js.
32+
var fs = require.nodeRequire('fs');
33+
fetchText = function (path, callback) {
34+
callback(fs.readFileSync(path, 'utf8'));
35+
};
36+
}
37+
4038
babel.registerPlugin('module-resolver', moduleResolver);
4139

4240
function resolvePath (sourcePath) {

0 commit comments

Comments
 (0)