Skip to content

Commit f0c3954

Browse files
committed
Update es6.js
1 parent a9bf319 commit f0c3954

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

es6.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,42 @@ if (typeof window !== "undefined" && window.navigator && window.document) {
2727

2828
define([
2929
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
30-
'babel'
30+
'babel',
3131
//>>excludeEnd('excludeBabel')
32+
'module'
3233
], function(
3334
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
34-
babel
35+
babel,
3536
//>>excludeEnd('excludeBabel')
37+
_module
3638
) {
3739
return {
3840
load: function (name, req, onload, config) {
3941
//>>excludeStart('excludeBabel', pragmas.excludeBabel)
40-
var url = req.toUrl(name + '.js');
41-
42-
fetchText(url, function (text) {
43-
var code = babel.transform(text, {
42+
function applyOptions(options) {
43+
var defaults = {
4444
modules: 'amd',
4545
sourceMap: config.isBuild ? false :'inline',
4646
sourceFileName: name,
4747
stage: 1
48-
}).code;
48+
};
49+
for(var key in options) {
50+
if(options.hasOwnProperty(key)) {
51+
defaults[key] = options[key];
52+
}
53+
}
54+
return defaults;
55+
}
56+
var url = req.toUrl(name + '.js');
57+
58+
fetchText(url, function (text) {
59+
var code = babel.transform(text, applyOptions(_module.config())).code;
4960

5061
if (config.isBuild) {
5162
_buildMap[name] = code;
5263
}
5364

54-
onload.fromText(code);
65+
onload.fromText(code);
5566
});
5667
//>>excludeEnd('excludeBabel')
5768
},

0 commit comments

Comments
 (0)